diff --git a/src/components/Timeline.vue b/src/components/Timeline.vue index 0b805db6..f01e82e5 100644 --- a/src/components/Timeline.vue +++ b/src/components/Timeline.vue @@ -32,6 +32,11 @@ v-show="!$refs.topmatter.type && list.length > 0"> {{ getViewName() }} + + + @@ -109,6 +114,7 @@ import Folder from "./frame/Folder.vue"; import Tag from "./frame/Tag.vue"; import Photo from "./frame/Photo.vue"; import TopMatter from "./top-matter/TopMatter.vue"; +import OnThisDay from "./top-matter/OnThisDay.vue"; import SelectionManager from './SelectionManager.vue'; import ScrollerManager from './ScrollerManager.vue'; import UserConfig from "../mixins/UserConfig"; @@ -128,6 +134,7 @@ const MOBILE_NUM_COLS = 3; // Number of columns on phone Tag, Photo, TopMatter, + OnThisDay, SelectionManager, ScrollerManager, NcEmptyContent, @@ -915,9 +922,9 @@ export default class Timeline extends Mixins(GlobalMixin, UserConfig) { * @param delPhotos photos to delete */ async deleteFromViewWithAnimation(delPhotos: IPhoto[]) { - if (delPhotos.length === 0) { - return; - } + // Only keep photos with day + delPhotos = delPhotos.filter(p => p.d); + if (delPhotos.length === 0) return; // Get all days that need to be updatd const updatedDays = new Set(delPhotos.map(p => p.d)); diff --git a/src/components/top-matter/OnThisDay.vue b/src/components/top-matter/OnThisDay.vue new file mode 100644 index 00000000..39b12022 --- /dev/null +++ b/src/components/top-matter/OnThisDay.vue @@ -0,0 +1,253 @@ + + + + + + + + {{ year.text }} + + + + + + + + {{ t('memories', 'Move left') }} + + + + + + + + {{ t('memories', 'Move right') }} + + + + + + + + + + + + \ No newline at end of file diff --git a/src/services/DavRequests.ts b/src/services/DavRequests.ts index 9a1ecc3b..d0cd8ce0 100644 --- a/src/services/DavRequests.ts +++ b/src/services/DavRequests.ts @@ -391,11 +391,10 @@ export async function downloadFilesByIds(fileIds: number[]) { } /** - * Get the onThisDay data - * Query for last 120 years; should be enough + * Get original onThisDay response. */ -export async function getOnThisDayData(): Promise { - const diffs: { [dayId: number]: number } = {}; +export async function getOnThisDayRaw() { + const dayIds: number[] = []; const now = new Date(); const nowUTC = new Date(now.getTime() - now.getTimezoneOffset() * 60000); @@ -407,20 +406,22 @@ export async function getOnThisDayData(): Promise { d.setFullYear(d.getFullYear() - i); d.setDate(d.getDate() + j); const dayId = Math.floor(d.getTime() / 1000 / 86400) - diffs[dayId] = i; + dayIds.push(dayId); } } + return (await axios.post(generateUrl('/apps/memories/api/days'), { + body_ids: dayIds.join(','), + })).data; +} + +/** + * Get the onThisDay data + * Query for last 120 years; should be enough + */ +export async function getOnThisDayData(): Promise { // Query for photos - let data: IPhoto[] = []; - try { - const res = await axios.post(generateUrl('/apps/memories/api/days'), { - body_ids: Object.keys(diffs).join(','), - }); - data = res.data; - } catch (e) { - throw e; - } + let data = await getOnThisDayRaw(); // Group photos by day const ans: IDay[] = []; diff --git a/src/services/Viewer.ts b/src/services/Viewer.ts index 9fddd61e..699c9945 100644 --- a/src/services/Viewer.ts +++ b/src/services/Viewer.ts @@ -21,19 +21,19 @@ export class ViewerManager { }); } - public async open(photo: IPhoto) { - const day = photo.d; - if (!day) return; + public async open(photo: IPhoto, list?: IPhoto[]) { + list = list || photo.d?.detail; + if (!list) return; // Repopulate map this.photoMap.clear(); - for (const p of day.detail) { + for (const p of list) { this.photoMap.set(p.fileid, p); } // Get file infos let fileInfos: IFileInfo[]; - const ids = day.detail.map(p => p.fileid); + const ids = list.map(p => p.fileid); try { this.updateLoading(1); fileInfos = await dav.getFiles(ids);