viewer: directly use timeline state
Signed-off-by: Varun Patil <radialapps@gmail.com>pull/900/head
parent
10ebef22d3
commit
3637965618
|
@ -292,7 +292,7 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_m.viewer.openDynamic(photo, this.list);
|
_m.viewer.openDynamic(photo, this);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -173,7 +173,7 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
|
|
||||||
import { IDay, IImageInfo, IPhoto, IRow, IRowType } from '../../types';
|
import { IImageInfo, IPhoto, IRowType, TimelineState } from '../../types';
|
||||||
import type { PsContent } from './types';
|
import type { PsContent } from './types';
|
||||||
|
|
||||||
import UserConfig from '../../mixins/UserConfig';
|
import UserConfig from '../../mixins/UserConfig';
|
||||||
|
@ -261,7 +261,6 @@ export default defineComponent({
|
||||||
psLivePhoto: null as PsLivePhoto | null,
|
psLivePhoto: null as PsLivePhoto | null,
|
||||||
|
|
||||||
list: [] as IPhoto[],
|
list: [] as IPhoto[],
|
||||||
days: new Map<number, IDay>(),
|
|
||||||
dayIds: [] as number[],
|
dayIds: [] as number[],
|
||||||
|
|
||||||
globalCount: 0,
|
globalCount: 0,
|
||||||
|
@ -568,7 +567,6 @@ export default defineComponent({
|
||||||
this.editorOpen = false;
|
this.editorOpen = false;
|
||||||
this.photoswipe = null;
|
this.photoswipe = null;
|
||||||
this.list = [];
|
this.list = [];
|
||||||
this.days.clear();
|
|
||||||
this.dayIds = [];
|
this.dayIds = [];
|
||||||
this.globalCount = 0;
|
this.globalCount = 0;
|
||||||
this.globalAnchor = -1;
|
this.globalAnchor = -1;
|
||||||
|
@ -648,7 +646,7 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
|
|
||||||
/** Open using start photo and rows list */
|
/** Open using start photo and rows list */
|
||||||
async openDynamic(anchorPhoto: IPhoto, rows: IRow[]) {
|
async openDynamic(anchorPhoto: IPhoto, timeline: TimelineState) {
|
||||||
const detail = anchorPhoto.d?.detail;
|
const detail = anchorPhoto.d?.detail;
|
||||||
if (!detail) {
|
if (!detail) {
|
||||||
console.error('Attempted to open viewer with no detail list!');
|
console.error('Attempted to open viewer with no detail list!');
|
||||||
|
@ -659,14 +657,13 @@ export default defineComponent({
|
||||||
const startIndex = detail.indexOf(anchorPhoto);
|
const startIndex = detail.indexOf(anchorPhoto);
|
||||||
|
|
||||||
// Get days list and map
|
// Get days list and map
|
||||||
for (const r of rows) {
|
for (const r of timeline.list) {
|
||||||
if (r.type === IRowType.HEAD) {
|
if (r.type === IRowType.HEAD) {
|
||||||
if (r.day.dayid == anchorPhoto.dayid) {
|
if (r.day.dayid == anchorPhoto.dayid) {
|
||||||
this.globalAnchor = this.globalCount;
|
this.globalAnchor = this.globalCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.globalCount += r.day.count;
|
this.globalCount += r.day.count;
|
||||||
this.days.set(r.day.dayid, r.day);
|
|
||||||
this.dayIds.push(r.day.dayid);
|
this.dayIds.push(r.day.dayid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -690,7 +687,7 @@ export default defineComponent({
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
const prevDayId = this.dayIds[firstDayIdx - 1];
|
const prevDayId = this.dayIds[firstDayIdx - 1];
|
||||||
const prevDay = this.days.get(prevDayId);
|
const prevDay = timeline.heads.get(prevDayId)?.day;
|
||||||
if (!prevDay?.detail) {
|
if (!prevDay?.detail) {
|
||||||
console.error('[BUG] No detail for previous day');
|
console.error('[BUG] No detail for previous day');
|
||||||
return {};
|
return {};
|
||||||
|
@ -706,7 +703,7 @@ export default defineComponent({
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
const nextDayId = this.dayIds[lastDayIdx + 1];
|
const nextDayId = this.dayIds[lastDayIdx + 1];
|
||||||
const nextDay = this.days.get(nextDayId);
|
const nextDay = timeline.heads.get(nextDayId)?.day;
|
||||||
if (!nextDay?.detail) {
|
if (!nextDay?.detail) {
|
||||||
console.error('[BUG] No detail for next day');
|
console.error('[BUG] No detail for next day');
|
||||||
return {};
|
return {};
|
||||||
|
@ -727,7 +724,7 @@ export default defineComponent({
|
||||||
for (let idx = dayIdx - 3; idx <= dayIdx + 3; idx++) {
|
for (let idx = dayIdx - 3; idx <= dayIdx + 3; idx++) {
|
||||||
if (idx < 0 || idx >= this.dayIds.length || idx === dayIdx) continue;
|
if (idx < 0 || idx >= this.dayIds.length || idx === dayIdx) continue;
|
||||||
|
|
||||||
const day = this.days.get(this.dayIds[idx]);
|
const day = timeline.heads.get(this.dayIds[idx])?.day;
|
||||||
if (day && !day?.detail) {
|
if (day && !day?.detail) {
|
||||||
// duplicate requests are skipped by Timeline
|
// duplicate requests are skipped by Timeline
|
||||||
utils.bus.emit('memories:timeline:fetch-day', day.dayid);
|
utils.bus.emit('memories:timeline:fetch-day', day.dayid);
|
||||||
|
|
|
@ -6,7 +6,7 @@ import type { translate, translatePlural } from '@nextcloud/l10n';
|
||||||
import type PlyrType from 'plyr';
|
import type PlyrType from 'plyr';
|
||||||
import type videojsType from 'video.js';
|
import type videojsType from 'video.js';
|
||||||
|
|
||||||
import type { IPhoto, IRow } from './types';
|
import type { IPhoto, TimelineState } from './types';
|
||||||
import type { constants, initstate } from './services/utils';
|
import type { constants, initstate } from './services/utils';
|
||||||
import type { GlobalRouteCheckers, routes } from './router';
|
import type { GlobalRouteCheckers, routes } from './router';
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ declare global {
|
||||||
|
|
||||||
viewer: {
|
viewer: {
|
||||||
open: (photo: IPhoto) => void;
|
open: (photo: IPhoto) => void;
|
||||||
openDynamic: (anchorPhoto: IPhoto, rows: IRow[]) => Promise<void>;
|
openDynamic: (anchorPhoto: IPhoto, timeline: TimelineState) => Promise<void>;
|
||||||
openStatic(photo: IPhoto, list: IPhoto[], thumbSize?: 256 | 512): Promise<void>;
|
openStatic(photo: IPhoto, list: IPhoto[], thumbSize?: 256 | 512): Promise<void>;
|
||||||
close: () => void;
|
close: () => void;
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
|
|
|
@ -302,3 +302,8 @@ export type IConfig = {
|
||||||
show_face_rect: boolean;
|
show_face_rect: boolean;
|
||||||
album_list_sort: 1 | 2;
|
album_list_sort: 1 | 2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export interface TimelineState {
|
||||||
|
list: IRow[];
|
||||||
|
heads: Map<number, IHeadRow>;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue