alinea 0.5.8 → 0.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{chunk-CMEMS6ZG.js → chunk-LVQI3LVE.js} +1 -1
- package/dist/cli/Serve.js +1 -1
- package/dist/cli/bin.js +1 -1
- package/dist/cli/generate/GenerateDashboard.js +1 -1
- package/dist/cloud/server/CloudAuthServer.js +1 -1
- package/dist/dashboard/atoms/DbAtoms.d.ts +2 -2
- package/dist/dashboard/atoms/DbAtoms.js +9 -3
- package/dist/dashboard/atoms/EntryAtoms.js +3 -1
- package/dist/dashboard/atoms/EntryEditorAtoms.js +10 -10
- package/dist/dashboard/hook/UseUploads.js +1 -1
- package/dist/dashboard/view/EntryTree.js +1 -2
- package/dist/dashboard/view/entry/NewEntry.js +8 -6
- package/package.json +1 -1
package/dist/cli/Serve.js
CHANGED
package/dist/cli/bin.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Graph } from 'alinea/core/Graph';
|
|
|
2
2
|
import { Mutation } from 'alinea/core/Mutation';
|
|
3
3
|
export declare const persistentStoreAtom: import("jotai").Atom<Promise<import("../util/PersistentStore.js").PersistentStore>>;
|
|
4
4
|
export declare const dbHashAtom: import("jotai").Atom<Promise<string>>;
|
|
5
|
-
export declare const mutateAtom: import("jotai").WritableAtom<null, Mutation[], Promise<void>> & {
|
|
5
|
+
export declare const mutateAtom: import("jotai").WritableAtom<null, [mutations: Mutation[], optimistic?: unknown], Promise<void>> & {
|
|
6
6
|
init: null;
|
|
7
7
|
};
|
|
8
8
|
export declare const dbUpdateAtom: import("jotai").WritableAtom<null, [force?: boolean | undefined], Promise<void>> & {
|
|
@@ -11,5 +11,5 @@ export declare const dbUpdateAtom: import("jotai").WritableAtom<null, [force?: b
|
|
|
11
11
|
export declare const graphAtom: import("jotai").Atom<Promise<Graph>>;
|
|
12
12
|
export declare const changedEntriesAtom: import("jotai").WritableAtom<string[], [i18nIds: string[]], void>;
|
|
13
13
|
export declare const entryRevisionAtoms: import("jotai/vanilla/utils/atomFamily.js").AtomFamily<string, import("jotai").WritableAtom<number, [], void>>;
|
|
14
|
-
export declare function useMutate(): (
|
|
14
|
+
export declare function useMutate(): (mutations: Mutation[], optimistic?: unknown) => Promise<void>;
|
|
15
15
|
export declare function useDbUpdater(everySeconds?: number): void;
|
|
@@ -123,7 +123,9 @@ var localDbAtom = atom(async (get, set) => {
|
|
|
123
123
|
return changed;
|
|
124
124
|
};
|
|
125
125
|
const debounceSync = (0, import_debounce_promise.default)(syncDb, 100);
|
|
126
|
-
const sync = (force) =>
|
|
126
|
+
const sync = (force) => {
|
|
127
|
+
return limit(() => debounceSync(force).catch(() => []));
|
|
128
|
+
};
|
|
127
129
|
const applyMutations = async (mutations, commitHash) => {
|
|
128
130
|
return limit(async () => {
|
|
129
131
|
const update = await db.applyMutations(mutations, commitHash);
|
|
@@ -182,13 +184,17 @@ async function suffixPaths(config, graph, mutations) {
|
|
|
182
184
|
}
|
|
183
185
|
var mutateAtom = atom(
|
|
184
186
|
null,
|
|
185
|
-
async (get, set,
|
|
187
|
+
async (get, set, mutations, optimistic = false) => {
|
|
186
188
|
const client = get(clientAtom);
|
|
187
189
|
const config = get(configAtom);
|
|
190
|
+
const { applyMutations } = await get(localDbAtom);
|
|
191
|
+
if (optimistic) {
|
|
192
|
+
const changed2 = await applyMutations(mutations, void 0);
|
|
193
|
+
set(changedEntriesAtom, changed2);
|
|
194
|
+
}
|
|
188
195
|
const graph = await get(graphAtom);
|
|
189
196
|
const normalized = await limit(() => suffixPaths(config, graph, mutations));
|
|
190
197
|
const { commitHash } = await client.mutate(normalized);
|
|
191
|
-
const { applyMutations } = await get(localDbAtom);
|
|
192
198
|
if (normalized.length === 0)
|
|
193
199
|
return;
|
|
194
200
|
const changed = await applyMutations(normalized, commitHash);
|
|
@@ -143,14 +143,16 @@ function useEntryTreeProvider() {
|
|
|
143
143
|
const nextIndex = next?.getItemData()?.index ?? null;
|
|
144
144
|
try {
|
|
145
145
|
const newIndex = generateKeyBetween(previousIndex, nextIndex);
|
|
146
|
+
const mutations = [];
|
|
146
147
|
for (const entry of dropping.getItemData().entries) {
|
|
147
|
-
|
|
148
|
+
mutations.push({
|
|
148
149
|
type: MutationType.Order,
|
|
149
150
|
entryId: entry.entryId,
|
|
150
151
|
file: entryFileName(config, entry, entry.parentPaths),
|
|
151
152
|
index: newIndex
|
|
152
153
|
});
|
|
153
154
|
}
|
|
155
|
+
mutate(mutations, true);
|
|
154
156
|
} catch (err) {
|
|
155
157
|
console.error(err);
|
|
156
158
|
}
|
|
@@ -244,7 +244,7 @@ function createEntryEditor(entryData) {
|
|
|
244
244
|
return set(transact, {
|
|
245
245
|
clearChanges: true,
|
|
246
246
|
transition: 0 /* SaveDraft */,
|
|
247
|
-
action: () => set(mutateAtom, mutation),
|
|
247
|
+
action: () => set(mutateAtom, [mutation]),
|
|
248
248
|
errorMessage: "Could not complete save action, please try again later"
|
|
249
249
|
});
|
|
250
250
|
});
|
|
@@ -284,7 +284,7 @@ function createEntryEditor(entryData) {
|
|
|
284
284
|
return set(transact, {
|
|
285
285
|
clearChanges: true,
|
|
286
286
|
transition: 1 /* SaveTranslation */,
|
|
287
|
-
action: () => set(mutateAtom, mutation),
|
|
287
|
+
action: () => set(mutateAtom, [mutation]),
|
|
288
288
|
errorMessage: "Could not complete translate action, please try again later"
|
|
289
289
|
});
|
|
290
290
|
});
|
|
@@ -330,7 +330,7 @@ function createEntryEditor(entryData) {
|
|
|
330
330
|
return set(transact, {
|
|
331
331
|
clearChanges: true,
|
|
332
332
|
transition: 2 /* PublishEdits */,
|
|
333
|
-
action: () => set(mutateAtom,
|
|
333
|
+
action: () => set(mutateAtom, mutations),
|
|
334
334
|
errorMessage: "Could not complete publish action, please try again later"
|
|
335
335
|
});
|
|
336
336
|
});
|
|
@@ -358,7 +358,7 @@ function createEntryEditor(entryData) {
|
|
|
358
358
|
return set(transact, {
|
|
359
359
|
clearChanges: true,
|
|
360
360
|
transition: 3 /* RestoreRevision */,
|
|
361
|
-
action: () => set(mutateAtom, mutation),
|
|
361
|
+
action: () => set(mutateAtom, [mutation]),
|
|
362
362
|
errorMessage: "Could not complete publish action, please try again later"
|
|
363
363
|
});
|
|
364
364
|
});
|
|
@@ -376,7 +376,7 @@ function createEntryEditor(entryData) {
|
|
|
376
376
|
mutations.push(...await persistSharedFields(graph, entry));
|
|
377
377
|
return set(transact, {
|
|
378
378
|
transition: 4 /* PublishDraft */,
|
|
379
|
-
action: () => set(mutateAtom,
|
|
379
|
+
action: () => set(mutateAtom, mutations),
|
|
380
380
|
errorMessage: "Could not complete publish action, please try again later"
|
|
381
381
|
});
|
|
382
382
|
});
|
|
@@ -388,7 +388,7 @@ function createEntryEditor(entryData) {
|
|
|
388
388
|
};
|
|
389
389
|
return set(transact, {
|
|
390
390
|
transition: 5 /* DiscardDraft */,
|
|
391
|
-
action: () => set(mutateAtom, mutation),
|
|
391
|
+
action: () => set(mutateAtom, [mutation]),
|
|
392
392
|
errorMessage: "Could not complete discard action, please try again later"
|
|
393
393
|
});
|
|
394
394
|
});
|
|
@@ -401,7 +401,7 @@ function createEntryEditor(entryData) {
|
|
|
401
401
|
};
|
|
402
402
|
return set(transact, {
|
|
403
403
|
transition: 6 /* ArchivePublished */,
|
|
404
|
-
action: () => set(mutateAtom, mutation),
|
|
404
|
+
action: () => set(mutateAtom, [mutation]),
|
|
405
405
|
errorMessage: "Could not complete archive action, please try again later"
|
|
406
406
|
});
|
|
407
407
|
});
|
|
@@ -415,7 +415,7 @@ function createEntryEditor(entryData) {
|
|
|
415
415
|
};
|
|
416
416
|
return set(transact, {
|
|
417
417
|
transition: 7 /* PublishArchived */,
|
|
418
|
-
action: () => set(mutateAtom, mutation),
|
|
418
|
+
action: () => set(mutateAtom, [mutation]),
|
|
419
419
|
errorMessage: "Could not complete publish action, please try again later"
|
|
420
420
|
});
|
|
421
421
|
});
|
|
@@ -435,7 +435,7 @@ function createEntryEditor(entryData) {
|
|
|
435
435
|
};
|
|
436
436
|
return set(transact, {
|
|
437
437
|
transition: 8 /* DeleteFile */,
|
|
438
|
-
action: () => set(mutateAtom, mutation),
|
|
438
|
+
action: () => set(mutateAtom, [mutation]),
|
|
439
439
|
errorMessage: "Could not complete delete action, please try again later"
|
|
440
440
|
});
|
|
441
441
|
});
|
|
@@ -448,7 +448,7 @@ function createEntryEditor(entryData) {
|
|
|
448
448
|
};
|
|
449
449
|
return set(transact, {
|
|
450
450
|
transition: 9 /* DeleteArchived */,
|
|
451
|
-
action: () => set(mutateAtom, mutation),
|
|
451
|
+
action: () => set(mutateAtom, [mutation]),
|
|
452
452
|
errorMessage: "Could not complete delete action, please try again later"
|
|
453
453
|
});
|
|
454
454
|
});
|
|
@@ -623,7 +623,7 @@ function createBatch(mutate) {
|
|
|
623
623
|
async function run() {
|
|
624
624
|
const todo = batch.splice(0, batch.length);
|
|
625
625
|
try {
|
|
626
|
-
await batchTasker(() => mutate(
|
|
626
|
+
await batchTasker(() => mutate(todo));
|
|
627
627
|
trigger.resolve(void 0);
|
|
628
628
|
} catch (error) {
|
|
629
629
|
trigger.reject(error);
|
|
@@ -884,7 +884,7 @@ import { IcRoundKeyboardArrowDown } from "alinea/ui/icons/IcRoundKeyboardArrowDo
|
|
|
884
884
|
import { IcRoundKeyboardArrowRight } from "alinea/ui/icons/IcRoundKeyboardArrowRight";
|
|
885
885
|
import { IcRoundTranslate } from "alinea/ui/icons/IcRoundTranslate";
|
|
886
886
|
import { useEffect, useRef } from "react";
|
|
887
|
-
import { changedEntriesAtom
|
|
887
|
+
import { changedEntriesAtom } from "../atoms/DbAtoms.js";
|
|
888
888
|
import {
|
|
889
889
|
rootId,
|
|
890
890
|
useEntryTreeProvider
|
|
@@ -987,7 +987,6 @@ function EntryTreeItem({ item, data }) {
|
|
|
987
987
|
);
|
|
988
988
|
}
|
|
989
989
|
function EntryTree({ i18nId: entryId, selected = [] }) {
|
|
990
|
-
const graph = useAtomValue(graphAtom);
|
|
991
990
|
const root = useRoot();
|
|
992
991
|
const treeProvider = useEntryTreeProvider();
|
|
993
992
|
const navigate = useNavigate();
|
|
@@ -237,12 +237,14 @@ function NewEntryForm({ parentId }) {
|
|
|
237
237
|
data: { ...entryData, title, path },
|
|
238
238
|
searchableText: ""
|
|
239
239
|
});
|
|
240
|
-
return mutate(
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
240
|
+
return mutate([
|
|
241
|
+
{
|
|
242
|
+
type: MutationType.Create,
|
|
243
|
+
entryId: entry.entryId,
|
|
244
|
+
entry,
|
|
245
|
+
file: entryFileName(config, data, parentPaths)
|
|
246
|
+
}
|
|
247
|
+
]).then(() => {
|
|
246
248
|
setIsCreating(false);
|
|
247
249
|
navigate(nav.entry({ entryId: entry.i18nId }));
|
|
248
250
|
if (parent)
|