From 88e2640e57609c609f6eaaacf9e86f7756fc9d80 Mon Sep 17 00:00:00 2001 From: Travis1282 Date: Tue, 5 Dec 2023 00:26:24 -0600 Subject: [PATCH 1/7] track time traveller update times to compare with draft update times, save notify about changes --- src/components/TopBar/TopBar.js | 8 +++++++- src/core/TimeTraveller.js | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/TopBar/TopBar.js b/src/components/TopBar/TopBar.js index 305d8d14c5..2da9bd515c 100644 --- a/src/components/TopBar/TopBar.js +++ b/src/components/TopBar/TopBar.js @@ -19,6 +19,12 @@ export const TopBar = observer(({ store }) => { const isViewAll = annotationStore?.viewingAll === true; + const toggleViewAll = async () => { + !isViewAll && await store.submitDraft(annotationStore.selected, { useToast: true }); + annotationStore.toggleViewingAllAnnotations(); + }; + + return store ? ( {isFF(FF_DEV_3873) ? ( @@ -31,7 +37,7 @@ export const TopBar = observer(({ store }) => { icon={} type="text" aria-label="View All" - onClick={() => annotationStore.toggleViewingAllAnnotations()} + onClick={toggleViewAll} primary={ isViewAll } style={{ height: 36, diff --git a/src/core/TimeTraveller.js b/src/core/TimeTraveller.js index 1ee9144113..a1108fde2a 100644 --- a/src/core/TimeTraveller.js +++ b/src/core/TimeTraveller.js @@ -9,7 +9,7 @@ const TimeTraveller = types undoIdx: 0, targetPath: '', skipNextUndoState: types.optional(types.boolean, false), - + lastAdditionTime: types.optional(types.Date, () => new Date()), createdIdx: 0, }) .volatile(() => ({ @@ -77,6 +77,7 @@ const TimeTraveller = types }, onUpdate(handler) { + this.lastAdditionTime = new Date(); updateHandlers.add(handler); return () => { updateHandlers.delete(handler); From 8955445652ab6f32fcae0f0c501e98dc18070067 Mon Sep 17 00:00:00 2001 From: Travis Clark Date: Fri, 8 Dec 2023 11:41:42 -0600 Subject: [PATCH 2/7] change where lastUpdate is set --- src/core/TimeTraveller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/TimeTraveller.js b/src/core/TimeTraveller.js index a1108fde2a..01fe0a319f 100644 --- a/src/core/TimeTraveller.js +++ b/src/core/TimeTraveller.js @@ -77,7 +77,6 @@ const TimeTraveller = types }, onUpdate(handler) { - this.lastAdditionTime = new Date(); updateHandlers.add(handler); return () => { updateHandlers.delete(handler); @@ -103,6 +102,7 @@ const TimeTraveller = types self.undoIdx = self.history.length - 1; replaceNextUndoState = false; changesDuringFreeze = false; + this.lastAdditionTime = new Date(); }, reinit(force = true) { From c0b8b0a1105ee1052678bcb12718b6ab8aeb8c9d Mon Sep 17 00:00:00 2001 From: Travis Clark Date: Fri, 8 Dec 2023 14:49:33 -0600 Subject: [PATCH 3/7] serialize before draft save, pass params --- src/components/TopBar/Actions.js | 1 + src/components/TopBar/TopBar.js | 5 ++--- src/stores/Annotation/Annotation.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/TopBar/Actions.js b/src/components/TopBar/Actions.js index d2aa00c722..a130c6b91c 100644 --- a/src/components/TopBar/Actions.js +++ b/src/components/TopBar/Actions.js @@ -15,6 +15,7 @@ export const Actions = ({ store }) => { const isViewAll = annotationStore.viewingAll; const onToggleVisibility = useCallback(() => { + !isViewAll && entity.saveDraftImmediatelyWithResults({useToast: true}); annotationStore.toggleViewingAllAnnotations(); }, [annotationStore]); diff --git a/src/components/TopBar/TopBar.js b/src/components/TopBar/TopBar.js index 2da9bd515c..d0d1d055f2 100644 --- a/src/components/TopBar/TopBar.js +++ b/src/components/TopBar/TopBar.js @@ -19,12 +19,11 @@ export const TopBar = observer(({ store }) => { const isViewAll = annotationStore?.viewingAll === true; - const toggleViewAll = async () => { - !isViewAll && await store.submitDraft(annotationStore.selected, { useToast: true }); + const toggleViewAll = () => { + !isViewAll && entity.saveDraftImmediatelyWithResults({useToast: true}); annotationStore.toggleViewingAllAnnotations(); }; - return store ? ( {isFF(FF_DEV_3873) ? ( diff --git a/src/stores/Annotation/Annotation.js b/src/stores/Annotation/Annotation.js index 6eb6b5242e..c4b8161d89 100644 --- a/src/stores/Annotation/Annotation.js +++ b/src/stores/Annotation/Annotation.js @@ -696,11 +696,11 @@ export const Annotation = types if (self.autosave) self.autosave.flush(); }, - async saveDraftImmediatelyWithResults() { + async saveDraftImmediatelyWithResults(params) { // There is no draft to save as it was already saved as an annotation if (self.submissionStarted || self.isDraftSaving) return {}; self.setDraftSaving(true); - const res = await self.saveDraft(null); + const res = await self.saveDraft(params); return res; }, From 6f595429d61529cbee47377c2342c759912d25d9 Mon Sep 17 00:00:00 2001 From: Travis Date: Wed, 27 Dec 2023 20:57:54 -0600 Subject: [PATCH 4/7] fix time traveller time save --- src/core/TimeTraveller.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/TimeTraveller.js b/src/core/TimeTraveller.js index 01fe0a319f..6be5a9fa7c 100644 --- a/src/core/TimeTraveller.js +++ b/src/core/TimeTraveller.js @@ -9,7 +9,7 @@ const TimeTraveller = types undoIdx: 0, targetPath: '', skipNextUndoState: types.optional(types.boolean, false), - lastAdditionTime: types.optional(types.Date, () => new Date()), + lastAdditionTime: types.optional(types.Date, new Date()), createdIdx: 0, }) .volatile(() => ({ @@ -102,7 +102,7 @@ const TimeTraveller = types self.undoIdx = self.history.length - 1; replaceNextUndoState = false; changesDuringFreeze = false; - this.lastAdditionTime = new Date(); + self.lastAdditionTime = new Date(); }, reinit(force = true) { From 4b1b287290342994ac6d239aee4ff03a0869c839 Mon Sep 17 00:00:00 2001 From: Travis Date: Thu, 4 Jan 2024 09:42:43 -0600 Subject: [PATCH 5/7] space around objects, es lint fix --- src/components/TopBar/Actions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TopBar/Actions.js b/src/components/TopBar/Actions.js index a130c6b91c..e379080fcf 100644 --- a/src/components/TopBar/Actions.js +++ b/src/components/TopBar/Actions.js @@ -15,7 +15,7 @@ export const Actions = ({ store }) => { const isViewAll = annotationStore.viewingAll; const onToggleVisibility = useCallback(() => { - !isViewAll && entity.saveDraftImmediatelyWithResults({useToast: true}); + !isViewAll && entity.saveDraftImmediatelyWithResults({ useToast: true }); annotationStore.toggleViewingAllAnnotations(); }, [annotationStore]); From 629c4542b57effada063e1d3e559c1290cf541fd Mon Sep 17 00:00:00 2001 From: Travis Clark Date: Thu, 4 Jan 2024 09:53:54 -0600 Subject: [PATCH 6/7] Update src/components/TopBar/TopBar.js Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/components/TopBar/TopBar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TopBar/TopBar.js b/src/components/TopBar/TopBar.js index d0d1d055f2..65dfc78fc4 100644 --- a/src/components/TopBar/TopBar.js +++ b/src/components/TopBar/TopBar.js @@ -20,7 +20,7 @@ export const TopBar = observer(({ store }) => { const isViewAll = annotationStore?.viewingAll === true; const toggleViewAll = () => { - !isViewAll && entity.saveDraftImmediatelyWithResults({useToast: true}); + !isViewAll && entity.saveDraftImmediatelyWithResults({ useToast: true}); annotationStore.toggleViewingAllAnnotations(); }; From cfd4403f30f9814c45294bda5d3f436183e63e74 Mon Sep 17 00:00:00 2001 From: Travis Date: Thu, 4 Jan 2024 10:08:48 -0600 Subject: [PATCH 7/7] appease linter again with space around objects --- src/components/TopBar/TopBar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TopBar/TopBar.js b/src/components/TopBar/TopBar.js index d0d1d055f2..a55e9aef64 100644 --- a/src/components/TopBar/TopBar.js +++ b/src/components/TopBar/TopBar.js @@ -20,7 +20,7 @@ export const TopBar = observer(({ store }) => { const isViewAll = annotationStore?.viewingAll === true; const toggleViewAll = () => { - !isViewAll && entity.saveDraftImmediatelyWithResults({useToast: true}); + !isViewAll && entity.saveDraftImmediatelyWithResults({ useToast: true }); annotationStore.toggleViewingAllAnnotations(); };