Studies: Finished & archived section with Archive/Restore
Build and Push Docker Image / build-and-push (push) Successful in 6m3s
Build and Push Docker Image / build-and-push (push) Successful in 6m3s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
afc3206da4
commit
843056b963
6 files changed
+140
-74
No files matched your search
@@ -200,17 +200,16 @@ export function useProjectLibrary({
|
||||
}
|
||||
};
|
||||
|
||||
// Puts a study in a series ("Romans", "Advent 2026"), or takes it out (an empty name).
|
||||
const setProjectSeries = (id, series) => {
|
||||
// Changes one top-level field of a stored study (from Home, without opening it) and syncs it.
|
||||
const patchStoredStudy = (id, patch) => {
|
||||
const loaded = loadProjectById(id);
|
||||
if (!loaded) return;
|
||||
const name = String(series ?? '').trim().slice(0, 80);
|
||||
if ((loaded.series ?? '') === name) return;
|
||||
const updated = { ...loaded, series: name, lastEdited: Date.now() };
|
||||
if (Object.entries(patch).every(([k, v]) => (loaded[k] ?? (typeof v === 'boolean' ? false : '')) === v)) return;
|
||||
const updated = { ...loaded, ...patch, lastEdited: Date.now() };
|
||||
saveProjectToStorage(updated);
|
||||
unsyncedStudies.add(id);
|
||||
setProjectIndex(loadProjectIndex());
|
||||
if (project?.id === id) setProject((current) => (current ? { ...current, series: name } : current));
|
||||
if (project?.id === id) setProject((current) => (current ? { ...current, ...patch } : current));
|
||||
saveRemoteProject(updated, { baseEdited: getSyncBase(id) }).then((result) => {
|
||||
if (result.ok) {
|
||||
const serverEdited = result.data?.lastEdited ?? updated.lastEdited;
|
||||
@@ -221,6 +220,12 @@ export function useProjectLibrary({
|
||||
});
|
||||
};
|
||||
|
||||
// Puts a study in a series ("Romans", "Advent 2026"), or takes it out (an empty name).
|
||||
const setProjectSeries = (id, series) => patchStoredStudy(id, { series: String(series ?? '').trim().slice(0, 80) });
|
||||
|
||||
// Moves a study to (or back from) the "Finished & archived" section on Home.
|
||||
const setProjectArchived = (id, archived) => patchStoredStudy(id, { archived: !!archived });
|
||||
|
||||
// Changes one chunk of a stored study (from Home, without opening it) and syncs it. `change` takes the chunk, returns the new one.
|
||||
const updateStoredChunk = (id, chunkId, change) => {
|
||||
const loaded = loadProjectById(id);
|
||||
@@ -318,6 +323,7 @@ export function useProjectLibrary({
|
||||
openStudyChunk,
|
||||
renameProjectInStorage,
|
||||
setProjectSeries,
|
||||
setProjectArchived,
|
||||
saveChunkRecall,
|
||||
saveChunkPatch,
|
||||
deleteProject,
|
||||
|
||||
Reference in new issue
Block a user