diff --git a/src/native/days.ts b/src/native/days.ts index 7213d9ca..6cf35e34 100644 --- a/src/native/days.ts +++ b/src/native/days.ts @@ -2,7 +2,7 @@ import { NAPI, nativex } from './api'; import { has } from './basic'; import { API } from '@services/API'; -import * as utils from '@services/utils'; +import { bus, setRenewingTimeout } from '@services/utils'; import type { IDay, IPhoto } from '@typings'; @@ -14,7 +14,9 @@ const seenABUIDs = new Set(); // Clear the cache whenever the timeline is refreshed if (has()) { - utils.onDOMLoaded(() => utils.bus.on('nativex:db:updated', () => daysCache.clear())); + document.addEventListener('DOMContentLoaded', () => { + bus.on('nativex:db:updated', () => daysCache.clear()); + }); } /** @@ -106,7 +108,7 @@ export function processFreshServerDay(this: any, dayId: number, photos: IPhoto[] } // Debounce - utils.setRenewingTimeout( + setRenewingTimeout( this, 'pfsdq_timer', () => { diff --git a/src/services/utils/helpers.ts b/src/services/utils/helpers.ts index 7f7eb22e..417c6ac3 100644 --- a/src/services/utils/helpers.ts +++ b/src/services/utils/helpers.ts @@ -3,7 +3,8 @@ import { getCurrentUser } from '@nextcloud/auth'; import { constants as c } from './const'; import { API } from '@services/API'; -import * as nativex from '@native'; +import { NAPI } from '@native'; + import type { IImageInfo, IPhoto } from '@typings'; /** @@ -67,7 +68,7 @@ export function getPreviewUrl(opts: PreviewOptsSize | PreviewOptsMsize | Preview // Native preview if (isLocalPhoto(photo)) { - return API.Q(nativex.NAPI.IMAGE_PREVIEW(photo.fileid), { c: photo.etag }); + return API.Q(NAPI.IMAGE_PREVIEW(photo.fileid), { c: photo.etag }); } // Screen-appropriate size @@ -115,7 +116,7 @@ export function getImageInfoUrl(photo: IPhoto | number): string { const fileid = typeof photo === 'number' ? photo : photo.fileid; if (typeof photo === 'object' && isLocalPhoto(photo)) { - return nativex.NAPI.IMAGE_INFO(fileid); + return NAPI.IMAGE_INFO(fileid); } return API.IMAGE_INFO(fileid);