Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@
"@solid-primitives/transition-group": "1.1.2",
"@solidjs/meta": "0.29.4",
"@tanstack/pacer-lite": "0.2.2",
"@tanstack/query-db-collection": "1.0.40",
"@tanstack/solid-db": "0.2.22",
"@tanstack/query-db-collection": "1.4.8",
"@tanstack/solid-db": "0.3.12",
"@tanstack/solid-form": "1.33.0",
"@tanstack/solid-hotkeys": "0.10.0",
"@tanstack/solid-query": "5.101.0",
"@tanstack/solid-query": "5.104.5",
"@tanstack/solid-router": "1.170.38",
"@tanstack/solid-table": "8.21.3",
"@ts-rest/core": "3.52.1",
Expand Down Expand Up @@ -81,9 +81,9 @@
"@solidjs/testing-library": "0.8.10",
"@tailwindcss/vite": "4.3.2",
"@tanstack/eslint-plugin-query": "5.101.0",
"@tanstack/solid-devtools": "0.8.5",
"@tanstack/solid-devtools": "0.8.13",
"@tanstack/solid-hotkeys-devtools": "0.7.0",
"@tanstack/solid-query-devtools": "5.101.0",
"@tanstack/solid-query-devtools": "5.104.5",
"@testing-library/dom": "10.4.1",
"@testing-library/jest-dom": "6.9.1",
"@testing-library/user-event": "14.6.1",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/ts/ape/server-configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function get(): Configuration | undefined {

export async function sync(): Promise<void> {
try {
await queryClient.fetchQuery(getServerConfigurationQueryOptions());
await queryClient.query(getServerConfigurationQueryOptions());
resolve(true);
} catch (e) {
reject(e);
Expand Down
36 changes: 17 additions & 19 deletions frontend/src/ts/collections/ape-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
setApeKeysDenied,
setLastGeneratedApeKey,
} from "../states/account-settings";
import { applyIdWorkaround, tempId } from "./utils/misc";
import { tempId } from "./utils/misc";
import { ApeKey } from "@monkeytype/schemas/ape-keys";
import { showSuccessNotification } from "../states/notifications";
import {
Expand Down Expand Up @@ -58,16 +58,14 @@ const apeKeysCollection = createCollection(
throw new Error(`Error fetching ape keys: ${response.body.message}`);
}

const dataArray = typedEntries(response.body.data)
.map(
([_id, data]) =>
({
...data,
_id,
name: replaceUnderscoresWithSpaces(data.name),
}) satisfies ApeKeyEntry,
)
.map(applyIdWorkaround);
const dataArray = typedEntries(response.body.data).map(
([_id, data]) =>
({
...data,
_id,
name: replaceUnderscoresWithSpaces(data.name),
}) satisfies ApeKeyEntry,
);

return dataArray;
},
Expand Down Expand Up @@ -108,7 +106,7 @@ const actions = {
name: replaceUnderscoresWithSpaces(name),
};

apeKeysCollection.utils.writeInsert(newKey);
await apeKeysCollection.utils.writeInsert(newKey);

setLastGeneratedApeKey(response.body.data.apeKey);
},
Expand All @@ -129,7 +127,7 @@ const actions = {
throw new Error(`Failed to update key: ${response.body.message}`);
}

apeKeysCollection.utils.writeUpdate({ _id: apeKeyId, enabled });
await apeKeysCollection.utils.writeUpdate({ _id: apeKeyId, enabled });

showSuccessNotification(`Key ${enabled ? "active" : "inactive"}`);
},
Expand All @@ -150,7 +148,7 @@ const actions = {
throw new Error(`Failed to update key: ${response.body.message}`);
}

apeKeysCollection.utils.writeUpdate({
await apeKeysCollection.utils.writeUpdate({
_id: apeKeyId,
name: replaceUnderscoresWithSpaces(name),
});
Expand All @@ -166,7 +164,7 @@ const actions = {
throw new Error(`Failed to delete key: ${response.body.message}`);
}

apeKeysCollection.utils.writeDelete(apeKeyId);
await apeKeysCollection.utils.writeDelete(apeKeyId);
},
}),
};
Expand All @@ -175,26 +173,26 @@ export async function insertApeKey(
params: ActionType["insertKey"],
): Promise<void> {
const transaction = actions.insertKey(params);
await transaction.isPersisted.promise;
await transaction.when("settled");
}

export async function updateApeKeyEnabled(
params: ActionType["setEnabled"],
): Promise<void> {
const transaction = actions.setEnabled(params);
await transaction.isPersisted.promise;
await transaction.when("settled");
}

export async function renameApeKey(
params: ActionType["rename"],
): Promise<void> {
const transaction = actions.rename(params);
await transaction.isPersisted.promise;
await transaction.when("settled");
}

export async function removeApeKey(
params: ActionType["remove"],
): Promise<void> {
const transaction = actions.remove(params);
await transaction.isPersisted.promise;
await transaction.when("settled");
}
20 changes: 10 additions & 10 deletions frontend/src/ts/collections/connections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { baseKey } from "../queries/utils/keys";
import { queryCollectionOptions } from "@tanstack/query-db-collection";
import { queryClient } from "../queries";
import Ape from "../ape";
import { applyIdWorkaround, tempId } from "./utils/misc";
import { tempId } from "./utils/misc";
import { getUserId, isAuthenticated } from "../states/core";

import {
Expand Down Expand Up @@ -48,7 +48,7 @@ const connectionsCollection = createCollection(
throw new Error(`Error fetching connections:${response.body.message}`);
}

return response.body.data.map(applyIdWorkaround);
return response.body.data;
},
}),
);
Expand Down Expand Up @@ -125,7 +125,7 @@ const actions = {
`Failed to accept connection: ${response.body.message}`,
);
}
connectionsCollection.utils.writeUpdate({
await connectionsCollection.utils.writeUpdate({
_id: id,
status: "accepted",
});
Expand All @@ -145,7 +145,7 @@ const actions = {
if (response.status !== 200) {
throw new Error(`Failed to block connection: ${response.body.message}`);
}
connectionsCollection.utils.writeUpdate({
await connectionsCollection.utils.writeUpdate({
_id: id,
status: "blocked",
});
Expand All @@ -162,7 +162,7 @@ const actions = {
`Failed to reject connection: ${response.body.message}`,
);
}
connectionsCollection.utils.writeDelete(id);
await connectionsCollection.utils.writeDelete(id);

await invalidateFriendsList();
},
Expand All @@ -183,7 +183,7 @@ const actions = {
const response = await Ape.connections.create({ body: { receiverName } });

if (response.status === 200) {
connectionsCollection.utils.writeInsert(response.body.data);
await connectionsCollection.utils.writeInsert(response.body.data);
showNoticeNotification(`Request sent to ${receiverName}`);
} else {
throw new Error(`Failed to add connection: ${response.body.message}`);
Expand All @@ -207,28 +207,28 @@ export async function acceptConnection(
params: ActionType["acceptConnection"],
): Promise<void> {
const transaction = actions.acceptConnection(params);
await transaction.isPersisted.promise;
await transaction.when("settled");
}

export async function rejectConnection(
params: ActionType["rejectConnection"],
): Promise<void> {
const transaction = actions.rejectConnection(params);
await transaction.isPersisted.promise;
await transaction.when("settled");
}

export async function blockConnection(
params: ActionType["blockConnection"],
): Promise<void> {
const transaction = actions.blockConnection(params);
await transaction.isPersisted.promise;
await transaction.when("settled");
}

export async function addConnection(
params: ActionType["addConnection"],
): Promise<void> {
const transaction = actions.addConnection(params);
await transaction.isPersisted.promise;
await transaction.when("settled");
}

export function hasConnection(
Expand Down
16 changes: 8 additions & 8 deletions frontend/src/ts/collections/custom-themes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import Ape from "../ape";
import { queryClient } from "../queries";
import { baseKey } from "../queries/utils/keys";
import { applyIdWorkaround, tempId } from "./utils/misc";
import { tempId } from "./utils/misc";
import { isAuthenticated } from "../states/core";

export type CustomThemeItem = CustomTheme;
Expand Down Expand Up @@ -43,7 +43,7 @@ const customThemesCollection = createCollection(
`Error fetching custom themes: ${response.body.message}`,
);
}
return response.body.data.map(applyIdWorkaround);
return response.body.data;
},
}),
);
Expand Down Expand Up @@ -84,7 +84,7 @@ const actions = {
throw new Error("Failed to add custom theme: No data returned");
}

customThemesCollection.utils.writeInsert({
await customThemesCollection.utils.writeInsert({
_id: response.body.data._id,
name,
colors,
Expand All @@ -108,7 +108,7 @@ const actions = {
);
}

customThemesCollection.utils.writeUpdate({
await customThemesCollection.utils.writeUpdate({
_id: themeId,
name,
colors,
Expand All @@ -128,7 +128,7 @@ const actions = {
`Failed to delete custom theme: ${response.body.message}`,
);
}
customThemesCollection.utils.writeDelete(themeId);
await customThemesCollection.utils.writeDelete(themeId);
},
}),
};
Expand All @@ -149,21 +149,21 @@ export async function addCustomTheme(
params: ActionType["addCustomTheme"],
): Promise<void> {
const transaction = actions.addCustomTheme(params);
await transaction.isPersisted.promise;
await transaction.when("settled");
}

export async function editCustomTheme(
params: ActionType["editCustomTheme"],
): Promise<void> {
const transaction = actions.editCustomTheme(params);
await transaction.isPersisted.promise;
await transaction.when("settled");
}

export async function deleteCustomTheme(
params: ActionType["deleteCustomTheme"],
): Promise<void> {
const transaction = actions.deleteCustomTheme(params);
await transaction.isPersisted.promise;
await transaction.when("settled");
}

/**
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/ts/collections/inbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,12 @@ async function flushPendingChanges({
throw new Error(`Error updating user inbox: ${response.body.message}`);
}

inboxCollection.utils.writeBatch(() => {
updatedStatus.deleted?.forEach((deleted) =>
inboxCollection.utils.writeDelete(deleted.id),
await inboxCollection.utils.writeBatch(() => {
updatedStatus.deleted?.forEach(
(deleted) => void inboxCollection.utils.writeDelete(deleted.id),
);
updatedStatus.read?.forEach((read) => {
inboxCollection.utils.writeUpdate(read);
void inboxCollection.utils.writeUpdate(read);
});
});

Expand Down
24 changes: 11 additions & 13 deletions frontend/src/ts/collections/presets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Ape from "../ape";
import { queryClient } from "../queries";
import { baseKey } from "../queries/utils/keys";
import { ConfigGroupName } from "@monkeytype/schemas/configs";
import { applyIdWorkaround, tempId } from "./utils/misc";
import { tempId } from "./utils/misc";
import { isAuthenticated } from "../states/core";
import { replaceUnderscoresWithSpaces } from "../utils/strings";

Expand Down Expand Up @@ -44,12 +44,10 @@ const presetsCollection = createCollection(
throw new Error(`Error fetching presets:${response.body.message}`);
}

return response.body.data
.map((it) => ({
...it,
name: replaceUnderscoresWithSpaces(it.name),
}))
.map(applyIdWorkaround);
return response.body.data.map((it) => ({
...it,
name: replaceUnderscoresWithSpaces(it.name),
}));
},
}),
);
Expand Down Expand Up @@ -100,7 +98,7 @@ const actions = {
settingGroups,
};

presetsCollection.utils.writeInsert(newPreset);
await presetsCollection.utils.writeInsert(newPreset);
},
}),
editPreset: createOptimisticAction<ActionType["editPreset"]>({
Expand Down Expand Up @@ -138,7 +136,7 @@ const actions = {
}

// if this is missing getPreset is out of sync
presetsCollection.utils.writeUpdate({
await presetsCollection.utils.writeUpdate({
_id: presetId,
name: name.replace(/_/g, " "),
...(config !== undefined && { config }),
Expand All @@ -157,7 +155,7 @@ const actions = {
if (response.status !== 200) {
throw new Error(`Failed to delete preset: ${response.body.message}`);
}
presetsCollection.utils.writeDelete(presetId);
await presetsCollection.utils.writeDelete(presetId);
},
}),
};
Expand All @@ -181,21 +179,21 @@ export async function addPreset(
params: ActionType["addPreset"],
): Promise<void> {
const transaction = actions.addPreset(params);
await transaction.isPersisted.promise;
await transaction.when("settled");
}

export async function editPreset(
params: ActionType["editPreset"],
): Promise<void> {
const transaction = actions.editPreset(params);
await transaction.isPersisted.promise;
await transaction.when("settled");
}

export async function deletePreset(
params: ActionType["deletePreset"],
): Promise<void> {
const transaction = actions.deletePreset(params);
await transaction.isPersisted.promise;
await transaction.when("settled");
}

/**
Expand Down
Loading
Loading