Reset the whole recycler

pull/37/head
Varun Patil 2022-09-13 00:00:49 -07:00
parent c0ea836510
commit 361b6660b0
4 changed files with 24 additions and 26 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -23,7 +23,6 @@
:src="getSrc()" :src="getSrc()"
:key="data.fileid" :key="data.fileid"
ref="image"
@click="click" @click="click"
@error="error" @error="error"
@load="load" @load="load"
@ -53,7 +52,6 @@ export default class Photo extends Mixins(GlobalMixin) {
@Prop() data: IPhoto; @Prop() data: IPhoto;
@Prop() rowHeight: number; @Prop() rowHeight: number;
@Prop() day: IDay; @Prop() day: IDay;
@Prop() state: number;
@Emit('reprocess') emitReprocess(remIds: Set<number>, updatedDays: Set<IDay>) {} @Emit('reprocess') emitReprocess(remIds: Set<number>, updatedDays: Set<IDay>) {}
@Emit('select') emitSelect(data: IPhoto) {} @Emit('select') emitSelect(data: IPhoto) {}
@ -78,13 +76,6 @@ export default class Photo extends Mixins(GlobalMixin) {
return getPreviewUrl(this.data.fileid, this.data.etag); return getPreviewUrl(this.data.fileid, this.data.etag);
} }
mounted() {
// Check if already loaded
if ((<HTMLImageElement>this.$refs.image).complete) {
this.load();
}
}
/** Image loaded successfully */ /** Image loaded successfully */
load() { load() {
this.data.flag |= this.c.FLAG_LOADED; this.data.flag |= this.c.FLAG_LOADED;

View File

@ -2,6 +2,7 @@
<div class="container" ref="container" :class="{ 'icon-loading': loading }"> <div class="container" ref="container" :class="{ 'icon-loading': loading }">
<!-- Main recycler view for rows --> <!-- Main recycler view for rows -->
<RecycleScroller <RecycleScroller
:key="state"
ref="recycler" ref="recycler"
class="recycler" class="recycler"
:items="list" :items="list"
@ -22,15 +23,12 @@
<div class="photo" v-for="photo of item.photos" :key="photo.fileid"> <div class="photo" v-for="photo of item.photos" :key="photo.fileid">
<Folder v-if="photo.isfolder" <Folder v-if="photo.isfolder"
:key="state"
:data="photo" :data="photo"
:rowHeight="rowHeight" /> :rowHeight="rowHeight" />
<Photo v-else <Photo v-else
:key="state"
:data="photo" :data="photo"
:rowHeight="rowHeight" :rowHeight="rowHeight"
:day="item.day" :day="item.day"
:state="state"
@select="selectPhoto" @select="selectPhoto"
@reprocess="deleteFromViewWithAnimation" @reprocess="deleteFromViewWithAnimation"
@clickImg="clickPhoto" /> @clickImg="clickPhoto" />
@ -187,26 +185,35 @@ export default class Timeline extends Mixins(GlobalMixin) {
private state = Math.random(); private state = Math.random();
mounted() { mounted() {
this.handleResize(); this.createState();
this.fetchDays();
// Timeline recycler init
(this.$refs.recycler as any).$el.addEventListener('scroll', this.scrollPositionChange, false);
this.scrollPositionChange();
} }
@Watch('$route') @Watch('$route')
routeChange(from: any, to: any) { async routeChange(from: any, to: any) {
this.resetState(); await this.resetState();
this.fetchDays(); await this.createState();
}; }
beforeDestroy() { beforeDestroy() {
this.resetState(); this.resetState();
} }
/** Create new state */
async createState() {
// Wait for one tick before doing anything
await this.$nextTick();
// Get data
this.fetchDays();
// Timeline recycler init
this.handleResize();
(this.$refs.recycler as any).$el.addEventListener('scroll', this.scrollPositionChange, false);
this.scrollPositionChange();
}
/** Reset all state */ /** Reset all state */
resetState() { async resetState() {
this.clearSelection(); this.clearSelection();
this.loading = true; this.loading = true;
this.list = []; this.list = [];