diff --git a/packages/frontend/src/pages/settings/profile.vue b/packages/frontend/src/pages/settings/profile.vue index 03d31f870b..172fb454a4 100644 --- a/packages/frontend/src/pages/settings/profile.vue +++ b/packages/frontend/src/pages/settings/profile.vue @@ -204,23 +204,26 @@ function save() { } function changeAvatar(ev) { - selectFile(ev.currentTarget ?? ev.target, i18n.ts.avatar, true, $i.avatarId ? [ - { type: 'divider' }, - { - type: 'button', - text: i18n.ts.detach, - icon: 'ti ti-circle-x', - action: () => { - os.apiWithDialog('i/update', { - avatarId: null, - }).then(() => { - $i.avatarId = null; - $i.avatarUrl = null; - globalEvents.emit('requestClearPageCache'); - }); + selectFile(ev.currentTarget ?? ev.target, i18n.ts.avatar, { + excludeSensitive: true, + additionalMenu: $i.avatarId ? [ + { type: 'divider' }, + { + type: 'button', + text: i18n.ts.detach, + icon: 'ti ti-circle-x', + action: () => { + os.apiWithDialog('i/update', { + avatarId: null, + }).then(() => { + $i.avatarId = null; + $i.avatarUrl = null; + globalEvents.emit('requestClearPageCache'); + }); + }, }, - }, - ] : undefined).then(async (file) => { + ] : undefined, + }).then(async (file) => { let originalOrCropped = file; const { canceled } = await os.confirm({ @@ -247,23 +250,26 @@ function changeAvatar(ev) { } function changeBanner(ev) { - selectFile(ev.currentTarget ?? ev.target, i18n.ts.banner, true, $i.bannerId ? [ - { type: 'divider' }, - { - type: 'button', - text: i18n.ts.detach, - icon: 'ti ti-circle-x', - action: () => { - os.apiWithDialog('i/update', { - bannerId: null, - }).then(() => { - $i.bannerId = null; - $i.bannerUrl = null; - globalEvents.emit('requestClearPageCache'); - }); + selectFile(ev.currentTarget ?? ev.target, i18n.ts.banner, { + excludeSensitive: true, + additionalMenu: $i.bannerId ? [ + { type: 'divider' }, + { + type: 'button', + text: i18n.ts.detach, + icon: 'ti ti-circle-x', + action: () => { + os.apiWithDialog('i/update', { + bannerId: null, + }).then(() => { + $i.bannerId = null; + $i.bannerUrl = null; + globalEvents.emit('requestClearPageCache'); + }); + }, }, - }, - ] : undefined).then(async (file) => { + ] : undefined, + }).then(async (file) => { let originalOrCropped = file; const { canceled } = await os.confirm({ diff --git a/packages/frontend/src/scripts/select-file.ts b/packages/frontend/src/scripts/select-file.ts index 7df7efe5b4..daa3f760ac 100644 --- a/packages/frontend/src/scripts/select-file.ts +++ b/packages/frontend/src/scripts/select-file.ts @@ -81,7 +81,7 @@ export function chooseFileFromUrl(): Promise { }); } -function select(src: any, label: string | null, multiple: boolean, excludeSensitive: boolean, additionalMenu: MenuItem[] = []): Promise { +function select(src: any, label: string | null, multiple: boolean, excludeSensitive = false, additionalMenu: MenuItem[] = []): Promise { return new Promise((res, rej) => { const keepOriginal = ref(defaultStore.state.keepOriginalUploading); @@ -121,10 +121,10 @@ function select(src: any, label: string | null, multiple: boolean, excludeSensit }); } -export function selectFile(src: any, label: string | null = null, excludeSensitive = false, additionalMenu?: MenuItem[]): Promise { - return select(src, label, false, excludeSensitive, additionalMenu).then(files => files[0]); +export function selectFile(src: any, label: string | null = null, options?: { excludeSensitive?: boolean; additionalMenu?: MenuItem[]; }): Promise { + return select(src, label, false, options?.excludeSensitive, options?.additionalMenu).then(files => files[0]); } -export function selectFiles(src: any, label: string | null = null, excludeSensitive = false, additionalMenu?: MenuItem[]): Promise { - return select(src, label, true, excludeSensitive, additionalMenu); +export function selectFiles(src: any, label: string | null = null, options?: { excludeSensitive?: boolean; additionalMenu?: MenuItem[]; }): Promise { + return select(src, label, true, options?.excludeSensitive, options?.additionalMenu); }