aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/client/stores
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/stores')
-rw-r--r--src/client/stores/sync.test.tsx26
-rw-r--r--src/client/stores/sync.tsx54
2 files changed, 78 insertions, 2 deletions
diff --git a/src/client/stores/sync.test.tsx b/src/client/stores/sync.test.tsx
index 9c4e5c2..fee79d7 100644
--- a/src/client/stores/sync.test.tsx
+++ b/src/client/stores/sync.test.tsx
@@ -38,7 +38,18 @@ describe("useSync", () => {
decks: [],
cards: [],
reviewLogs: [],
- conflicts: { decks: [], cards: [] },
+ noteTypes: [],
+ noteFieldTypes: [],
+ notes: [],
+ noteFieldValues: [],
+ conflicts: {
+ decks: [],
+ cards: [],
+ noteTypes: [],
+ noteFieldTypes: [],
+ notes: [],
+ noteFieldValues: [],
+ },
currentSyncVersion: 0,
}),
});
@@ -138,7 +149,18 @@ describe("useSync", () => {
decks: [],
cards: [],
reviewLogs: [],
- conflicts: { decks: [], cards: [] },
+ noteTypes: [],
+ noteFieldTypes: [],
+ notes: [],
+ noteFieldValues: [],
+ conflicts: {
+ decks: [],
+ cards: [],
+ noteTypes: [],
+ noteFieldTypes: [],
+ notes: [],
+ noteFieldValues: [],
+ },
currentSyncVersion: 1,
}),
});
diff --git a/src/client/stores/sync.tsx b/src/client/stores/sync.tsx
index 29c6c4f..aea5c16 100644
--- a/src/client/stores/sync.tsx
+++ b/src/client/stores/sync.tsx
@@ -22,6 +22,10 @@ import {
import type {
ServerCard,
ServerDeck,
+ ServerNote,
+ ServerNoteFieldType,
+ ServerNoteFieldValue,
+ ServerNoteType,
ServerReviewLog,
SyncPullResult,
} from "../sync/pull";
@@ -73,6 +77,33 @@ interface PullResponse {
reviewedAt: string;
}
>;
+ noteTypes: Array<
+ Omit<ServerNoteType, "createdAt" | "updatedAt" | "deletedAt"> & {
+ createdAt: string;
+ updatedAt: string;
+ deletedAt: string | null;
+ }
+ >;
+ noteFieldTypes: Array<
+ Omit<ServerNoteFieldType, "createdAt" | "updatedAt" | "deletedAt"> & {
+ createdAt: string;
+ updatedAt: string;
+ deletedAt: string | null;
+ }
+ >;
+ notes: Array<
+ Omit<ServerNote, "createdAt" | "updatedAt" | "deletedAt"> & {
+ createdAt: string;
+ updatedAt: string;
+ deletedAt: string | null;
+ }
+ >;
+ noteFieldValues: Array<
+ Omit<ServerNoteFieldValue, "createdAt" | "updatedAt"> & {
+ createdAt: string;
+ updatedAt: string;
+ }
+ >;
currentSyncVersion: number;
}
@@ -141,6 +172,29 @@ async function pullFromServer(
...r,
reviewedAt: new Date(r.reviewedAt),
})),
+ noteTypes: data.noteTypes.map((n) => ({
+ ...n,
+ createdAt: new Date(n.createdAt),
+ updatedAt: new Date(n.updatedAt),
+ deletedAt: n.deletedAt ? new Date(n.deletedAt) : null,
+ })),
+ noteFieldTypes: data.noteFieldTypes.map((f) => ({
+ ...f,
+ createdAt: new Date(f.createdAt),
+ updatedAt: new Date(f.updatedAt),
+ deletedAt: f.deletedAt ? new Date(f.deletedAt) : null,
+ })),
+ notes: data.notes.map((n) => ({
+ ...n,
+ createdAt: new Date(n.createdAt),
+ updatedAt: new Date(n.updatedAt),
+ deletedAt: n.deletedAt ? new Date(n.deletedAt) : null,
+ })),
+ noteFieldValues: data.noteFieldValues.map((v) => ({
+ ...v,
+ createdAt: new Date(v.createdAt),
+ updatedAt: new Date(v.updatedAt),
+ })),
currentSyncVersion: data.currentSyncVersion,
};
}