From 97496ce7ab8a0208615f9552430ff9e7d53dcbc8 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Sun, 25 Sep 2022 07:53:14 -0700 Subject: [PATCH] Refresh on date change --- src/components/EditDate.vue | 2 ++ src/components/Timeline.vue | 20 +++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/components/EditDate.vue b/src/components/EditDate.vue index 3aff08c9..0477cfc0 100644 --- a/src/components/EditDate.vue +++ b/src/components/EditDate.vue @@ -237,6 +237,7 @@ export default class EditDate extends Mixins(GlobalMixin) { const res = await axios.patch(generateUrl(EDIT_API_URL, { id: this.photos[0].fileid }), { date: this.getExifFormat(this.getDate()), }); + this.$emit('refresh', true); this.close(); } catch (e) { if (e.response?.data?.message) { @@ -294,6 +295,7 @@ export default class EditDate extends Mixins(GlobalMixin) { // nothing to do } this.processing = false; + this.$emit('refresh', true); this.close(); } diff --git a/src/components/Timeline.vue b/src/components/Timeline.vue index 5610fd1b..413f2d59 100644 --- a/src/components/Timeline.vue +++ b/src/components/Timeline.vue @@ -120,7 +120,7 @@ - + @@ -240,8 +240,7 @@ export default class Timeline extends Mixins(GlobalMixin, UserConfig) { @Watch('$route') async routeChange(from: any, to: any) { - await this.resetState(); - await this.createState(); + await this.refresh(); } beforeDestroy() { @@ -302,6 +301,21 @@ export default class Timeline extends Mixins(GlobalMixin, UserConfig) { } } + /** Recreate everything */ + async refresh(preservePosition = false) { + // Get current scroll position + const origScroll = (this.$refs.recycler).$el.scrollTop; + + // Reset state + await this.resetState(); + await this.createState(); + + // Restore scroll position + if (preservePosition) { + (this.$refs.recycler).scrollToPosition(origScroll); + } + } + /** Do resize after some time */ handleResizeWithDelay() { if (this.resizeTimer) {