diff --git a/src/bootstrap.ts b/src/bootstrap.ts index 1aae8309..69221e3c 100644 --- a/src/bootstrap.ts +++ b/src/bootstrap.ts @@ -13,7 +13,7 @@ import VueVirtualScroller from 'vue-virtual-scroller'; // Locals import router from './router'; -import { c, initState } from './services/utils'; +import { constants, initstate } from './services/utils'; // CSS for components import 'vue-virtual-scroller/dist/vue-virtual-scroller.css'; @@ -67,7 +67,7 @@ Vue.component('XImg', XImg); Vue.component('XLoadingIcon', XLoadingIcon); // Register global constants and functions -Vue.prototype.c = c; -Vue.prototype.initState = initState; +Vue.prototype.c = constants; +Vue.prototype.initstate = initstate; Vue.prototype.t = translate; Vue.prototype.n = translatePlural; diff --git a/src/components/SelectionManager.vue b/src/components/SelectionManager.vue index 87e3de4a..8cc8c626 100644 --- a/src/components/SelectionManager.vue +++ b/src/components/SelectionManager.vue @@ -206,7 +206,7 @@ export default defineComponent({ icon: DownloadIcon, callback: this.downloadSelection.bind(this), allowPublic: true, - if: () => !this.initState.noDownload, + if: () => !this.initstate.noDownload, }, { name: t('memories', 'Favorite'), diff --git a/src/components/top-matter/FaceTopMatter.vue b/src/components/top-matter/FaceTopMatter.vue index ed0fc563..1fb3941e 100644 --- a/src/components/top-matter/FaceTopMatter.vue +++ b/src/components/top-matter/FaceTopMatter.vue @@ -109,7 +109,7 @@ export default defineComponent({ }, isReal() { - return this.name && this.name !== utils.c.FACE_NULL; + return this.name && this.name !== this.c.FACE_NULL; }, displayName() { @@ -138,7 +138,7 @@ export default defineComponent({ name: this.$route.name as string, params: { user: utils.uid as string, - name: utils.c.FACE_NULL, + name: this.c.FACE_NULL, }, }); }, diff --git a/src/components/top-matter/PublicShareHeader.ts b/src/components/top-matter/PublicShareHeader.ts index 6f912dea..00730639 100644 --- a/src/components/top-matter/PublicShareHeader.ts +++ b/src/components/top-matter/PublicShareHeader.ts @@ -1,7 +1,7 @@ import * as utils from '../../services/utils'; // Shown in dynamic top matter (Timeline::viewName) -export const title = utils.initState.shareTitle; +export const title = utils.initstate.shareTitle; // Set up hook to monitor recycler scroll to show/hide header if (title) { diff --git a/src/components/viewer/Viewer.vue b/src/components/viewer/Viewer.vue index 2e806480..fb064cc5 100644 --- a/src/components/viewer/Viewer.vue +++ b/src/components/viewer/Viewer.vue @@ -90,7 +90,7 @@ :aria-label="t('memories', 'Download')" @click="downloadCurrent" :close-after-click="true" - v-if="!initState.noDownload && !isLocal" + v-if="!initstate.noDownload && !isLocal" > {{ t('memories', 'Download') }} p.flag & utils.c.FLAG_IS_LOCAL); + const deleted = photos.filter((p) => p.flag & c.FLAG_IS_LOCAL); // Yield for the fully local files if (deleted.length > 0) { diff --git a/src/services/dav/face.ts b/src/services/dav/face.ts index a77d6ae7..5654603f 100644 --- a/src/services/dav/face.ts +++ b/src/services/dav/face.ts @@ -5,7 +5,7 @@ import { generateUrl } from '@nextcloud/router'; import { IFace, IPhoto } from '../../types'; import { API } from '../API'; import client from './client'; -import * as utils from '../utils'; +import { constants as c } from '../utils'; import * as base from './base'; /** @@ -93,7 +93,7 @@ export async function* recognizeMoveFaceImages(user: string, face: string, targe // NULL source needs special handling let source = `/recognize/${user}/faces/${face}`; - if (face === utils.c.FACE_NULL) { + if (face === c.FACE_NULL) { source = `/recognize/${user}/unassigned-faces`; } diff --git a/src/services/dav/favorites.ts b/src/services/dav/favorites.ts index 7d7e60fb..83fca2e3 100644 --- a/src/services/dav/favorites.ts +++ b/src/services/dav/favorites.ts @@ -3,7 +3,7 @@ import { translate as t } from '@nextcloud/l10n'; import { IFileInfo, IPhoto } from '../../types'; import client from './client'; import * as base from './base'; -import * as utils from '../utils'; +import { constants as c } from '../utils'; /** * Favorite a file @@ -83,8 +83,8 @@ export async function* favoritePhotos(photos: IPhoto[], favoriteState: boolean) */ export function favoriteSetFlag(photo: IPhoto, val: boolean) { if (val) { - photo.flag |= utils.c.FLAG_IS_FAVORITE; + photo.flag |= c.FLAG_IS_FAVORITE; } else { - photo.flag &= ~utils.c.FLAG_IS_FAVORITE; + photo.flag &= ~c.FLAG_IS_FAVORITE; } } diff --git a/src/services/dav/single-item.ts b/src/services/dav/single-item.ts index 8c24cdc1..1fb47c93 100644 --- a/src/services/dav/single-item.ts +++ b/src/services/dav/single-item.ts @@ -1,7 +1,7 @@ import { IDay } from '../../types'; -import * as utils from '../utils'; +import { initstate } from '../utils'; -const { singleItem } = utils.initState; +const { singleItem } = initstate; export function isSingleItem(): boolean { return Boolean(singleItem?.fileid); diff --git a/src/services/utils/const.ts b/src/services/utils/const.ts index e3357cae..775b409e 100644 --- a/src/services/utils/const.ts +++ b/src/services/utils/const.ts @@ -2,7 +2,7 @@ import { IPhoto } from '../../types'; import { loadState } from '@nextcloud/initial-state'; /** Global constants */ -export const c = Object.freeze({ +export const constants = Object.freeze({ // Flags for photos FLAG_PLACEHOLDER: 1 << 0, FLAG_LOAD_FAIL: 1 << 1, @@ -19,7 +19,7 @@ export const c = Object.freeze({ /** * Initial state pulled from Nextcloud's HTML page */ -export const initState = Object.freeze({ +export const initstate = Object.freeze({ noDownload: loadState('memories', 'no_download', false) !== false, shareTitle: loadState('memories', 'share_title', '') as string, singleItem: loadState('memories', 'single_item', null) as IPhoto | null, @@ -36,15 +36,15 @@ export function convertFlags(photo: IPhoto) { } if (photo.isvideo) { - photo.flag |= c.FLAG_IS_VIDEO; + photo.flag |= constants.FLAG_IS_VIDEO; delete photo.isvideo; } if (photo.isfavorite) { - photo.flag |= c.FLAG_IS_FAVORITE; + photo.flag |= constants.FLAG_IS_FAVORITE; delete photo.isfavorite; } if (photo.islocal) { - photo.flag |= c.FLAG_IS_LOCAL; + photo.flag |= constants.FLAG_IS_LOCAL; delete photo.islocal; } } @@ -59,7 +59,7 @@ export function copyPhotoFlags(src: IPhoto, dst: IPhoto) { const copy = (flag: number) => (dst.flag = src.flag & flag ? dst.flag | flag : dst.flag & ~flag); // copy all flags - copy(c.FLAG_IS_VIDEO); - copy(c.FLAG_IS_FAVORITE); - copy(c.FLAG_IS_LOCAL); + copy(constants.FLAG_IS_VIDEO); + copy(constants.FLAG_IS_FAVORITE); + copy(constants.FLAG_IS_LOCAL); } diff --git a/src/services/utils/helpers.ts b/src/services/utils/helpers.ts index 00cef6e0..5dd630c0 100644 --- a/src/services/utils/helpers.ts +++ b/src/services/utils/helpers.ts @@ -4,7 +4,7 @@ import { showError } from '@nextcloud/dialogs'; import { translate as t } from '@nextcloud/l10n'; import { API } from '../API'; -import { c } from './const'; +import { constants as c } from './const'; import * as nativex from '../../native'; import type { IImageInfo, IPhoto } from '../../types';