diff --git a/frontend/src/pages/photos.vue b/frontend/src/pages/photos.vue index b79dd3bc1..f1b49a239 100644 --- a/frontend/src/pages/photos.vue +++ b/frontend/src/pages/photos.vue @@ -494,17 +494,8 @@ export default { if (this.$root.$el.clientHeight <= window.document.documentElement.clientHeight + 300) { this.$emit("scrollRefresh"); } - const lastOpenedPhotoId = window.localStorage.getItem("last_opened_photo"); - if (!this.viewer.open && lastOpenedPhotoId) { - window.localStorage.removeItem("last_opened_photo"); - this.$nextTick(() => { - document.querySelector(`[data-uid="${lastOpenedPhotoId}"]`)?.scrollIntoView({ - behavior: 'auto', - block: 'center', - inline: 'center' - }); - }); - } + + this.restoreScrollPosition(); }); } }).finally(() => { @@ -513,6 +504,21 @@ export default { this.listen = true; }); }, + restoreScrollPosition() { + const lastOpenedPhotoId = window.localStorage.getItem("last_opened_photo"); + if (lastOpenedPhotoId === undefined || lastOpenedPhotoId === null || this.viewer.open) { + return; + } + + window.localStorage.removeItem("last_opened_photo"); + this.$nextTick(() => { + document.querySelector(`[data-uid="${lastOpenedPhotoId}"]`)?.scrollIntoView({ + behavior: 'auto', + block: 'center', + inline: 'center' + }); + }); + }, onImportCompleted() { if (!this.listen) return;