refactor: revert constants rename

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/877/head
Varun Patil 2023-10-16 11:23:01 -07:00
parent 2c18198c37
commit 0741eeb113
13 changed files with 31 additions and 30 deletions

View File

@ -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;

View File

@ -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'),

View File

@ -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,
},
});
},

View File

@ -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) {

View File

@ -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') }}
<template #icon>
@ -98,7 +98,7 @@
</template>
</NcActionButton>
<NcActionButton
v-if="!initState.noDownload && currentPhoto?.liveid"
v-if="!initstate.noDownload && currentPhoto?.liveid"
:aria-label="t('memories', 'Download Video')"
@click="downloadCurrentLiveVideo"
:close-after-click="true"

6
src/globals.d.ts vendored
View File

@ -7,7 +7,7 @@ import type PlyrType from 'plyr';
import type videojsType from 'video.js';
import type { IPhoto, IRow } from './types';
import type { c, initState } from './services/utils';
import type { constants, initstate } from './services/utils';
import type { GlobalRouteCheckers } from './router';
// Global exposed variables
@ -101,8 +101,8 @@ declare module 'vue' {
t: typeof translate;
n: typeof translatePlural;
c: typeof c;
initState: typeof initState;
c: typeof constants;
initstate: typeof initstate;
}
}

View File

@ -10,7 +10,7 @@ import SplitTimeline from './components/SplitTimeline.vue';
import ClusterView from './components/ClusterView.vue';
import NativeXSetup from './native/Setup.vue';
import { c } from './services/utils';
import { constants as c } from './services/utils';
// Routes are defined here
export type RouteId =

View File

@ -7,6 +7,7 @@ import { API } from '../API';
import { getAlbumFileInfos } from './albums';
import client from './client';
import * as utils from '../utils';
import { constants as c } from '../utils';
import * as nativex from '../../native';
const GET_FILE_CHUNK_SIZE = 50;
@ -233,7 +234,7 @@ export async function* deletePhotos(photos: IPhoto[], confirm: boolean = true) {
await nativex.deleteLocalPhotos(photos);
// Remove purely local files
const deleted = photos.filter((p) => 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) {

View File

@ -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`;
}

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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';