Refresh on date change

pull/62/head
Varun Patil 2022-09-25 07:53:14 -07:00
parent c7a60473a4
commit 97496ce7ab
2 changed files with 19 additions and 3 deletions

View File

@ -237,6 +237,7 @@ export default class EditDate extends Mixins(GlobalMixin) {
const res = await axios.patch<any>(generateUrl(EDIT_API_URL, { id: this.photos[0].fileid }), { const res = await axios.patch<any>(generateUrl(EDIT_API_URL, { id: this.photos[0].fileid }), {
date: this.getExifFormat(this.getDate()), date: this.getExifFormat(this.getDate()),
}); });
this.$emit('refresh', true);
this.close(); this.close();
} catch (e) { } catch (e) {
if (e.response?.data?.message) { if (e.response?.data?.message) {
@ -294,6 +295,7 @@ export default class EditDate extends Mixins(GlobalMixin) {
// nothing to do // nothing to do
} }
this.processing = false; this.processing = false;
this.$emit('refresh', true);
this.close(); this.close();
} }

View File

@ -120,7 +120,7 @@
</NcActions> </NcActions>
</div> </div>
<EditDate ref="editDate" /> <EditDate ref="editDate" @refresh="refresh" />
</div> </div>
</template> </template>
@ -240,8 +240,7 @@ export default class Timeline extends Mixins(GlobalMixin, UserConfig) {
@Watch('$route') @Watch('$route')
async routeChange(from: any, to: any) { async routeChange(from: any, to: any) {
await this.resetState(); await this.refresh();
await this.createState();
} }
beforeDestroy() { 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 = (<any>this.$refs.recycler).$el.scrollTop;
// Reset state
await this.resetState();
await this.createState();
// Restore scroll position
if (preservePosition) {
(<any>this.$refs.recycler).scrollToPosition(origScroll);
}
}
/** Do resize after some time */ /** Do resize after some time */
handleResizeWithDelay() { handleResizeWithDelay() {
if (this.resizeTimer) { if (this.resizeTimer) {