diff --git a/ui/app/components/ConditionForm.vue b/ui/app/components/ConditionForm.vue index e7ff9fed..b29bc385 100644 --- a/ui/app/components/ConditionForm.vue +++ b/ui/app/components/ConditionForm.vue @@ -343,7 +343,7 @@ const importItem = async (): Promise => { return } - if ((form.filter || form.cli) && !box.confirm('Overwrite the current form fields?', true)) { + if ((form.filter || form.cli) && !(await box.confirm('Overwrite the current form fields?', true))) { return } diff --git a/ui/app/components/History.vue b/ui/app/components/History.vue index 67c3980b..129b6b90 100644 --- a/ui/app/components/History.vue +++ b/ui/app/components/History.vue @@ -588,7 +588,7 @@ const hasDownloaded = computed(() => { return false }) -const deleteSelectedItems = () => { +const deleteSelectedItems = async () => { if (selectedElms.value.length < 1) { toast.error('No items selected.') return @@ -597,7 +597,7 @@ const deleteSelectedItems = () => { if (true === config.app.remove_files) { msg += ' This will remove any associated files if they exists.' } - if (false === box.confirm(msg, config.app.remove_files)) { + if (false === (await box.confirm(msg, config.app.remove_files))) { return } for (const key in selectedElms.value) { @@ -614,9 +614,9 @@ const deleteSelectedItems = () => { selectedElms.value = [] } -const clearCompleted = () => { +const clearCompleted = async () => { let msg = 'Clear all completed downloads?' - if (false === box.confirm(msg)) { + if (false === (await box.confirm(msg))) { return } for (const key in stateStore.history) { @@ -626,8 +626,8 @@ const clearCompleted = () => { } } -const clearIncomplete = () => { - if (false === box.confirm('Clear all in-complete downloads?')) { +const clearIncomplete = async () => { + if (false === (await box.confirm('Clear all in-complete downloads?'))) { return } for (const key in stateStore.history) { @@ -706,8 +706,8 @@ const setStatus = (item: StoreItem) => { return item.status } -const retryIncomplete = () => { - if (false === box.confirm('Retry all incomplete downloads?')) { +const retryIncomplete = async () => { + if (false === (await box.confirm('Retry all incomplete downloads?'))) { return false } for (const key in stateStore.history) { @@ -746,12 +746,12 @@ const archiveItem = async (item: StoreItem, opts = {}) => { socket.emit('item_delete', { id: item._id, remove_file: false }) } -const removeItem = (item: StoreItem) => { +const removeItem = async (item: StoreItem) => { let msg = `${config.app.remove_files ? 'Remove' : 'Clear'} '${item.title || item.id || item.url || '??'}'?` if (item.status === 'finished' && config.app.remove_files) { msg += ' This will remove any associated files if they exists.' } - if (false === box.confirm(msg, Boolean(item.filename && config.app.remove_files))) { + if (false === (await box.confirm(msg, Boolean(item.filename && config.app.remove_files)))) { return false } socket.emit('item_delete', { diff --git a/ui/app/components/NotificationForm.vue b/ui/app/components/NotificationForm.vue index 985cb5fc..a85267c5 100644 --- a/ui/app/components/NotificationForm.vue +++ b/ui/app/components/NotificationForm.vue @@ -373,7 +373,7 @@ const importItem = async () => { } if (form.name || form.request?.url) { - if (false === box.confirm('Overwrite the current form fields?', true)) { + if (false === (await box.confirm('Overwrite the current form fields?', true))) { return } } diff --git a/ui/app/components/Queue.vue b/ui/app/components/Queue.vue index 7ab145b4..d4d21476 100644 --- a/ui/app/components/Queue.vue +++ b/ui/app/components/Queue.vue @@ -507,16 +507,16 @@ const updateProgress = (item: StoreItem): string => { return string } -const confirmCancel = (item: StoreItem) => { - if (true !== box.confirm(`Cancel '${item.title}'?`)) { +const confirmCancel = async (item: StoreItem) => { + if (true !== (await box.confirm(`Cancel '${item.title}'?`))) { return false } cancelItems(item._id) return true } -const cancelSelected = () => { - if (true !== box.confirm(`Cancel '${selectedElms.value.length}' selected items?`)) { +const cancelSelected = async () => { + if (true !== (await box.confirm(`Cancel '${selectedElms.value.length}' selected items?`))) { return false } cancelItems(selectedElms.value) @@ -543,7 +543,7 @@ const cancelItems = (item: string | string[]) => { const startItem = (item: StoreItem) => socket.emit('item_start', item._id) const pauseItem = (item: StoreItem) => socket.emit('item_pause', item._id) -const startItems = () => { +const startItems = async () => { if (1 > selectedElms.value.length) { return } @@ -559,13 +559,13 @@ const startItems = () => { toast.error('No eligible items to start.') return } - if (true !== box.confirm(`Start '${filtered.length}' selected items?`)) { + if (true !== (await box.confirm(`Start '${filtered.length}' selected items?`))) { return false } filtered.forEach(id => socket.emit('item_start', id)) } -const pauseSelected = () => { +const pauseSelected = async () => { if (1 > selectedElms.value.length) { return } @@ -581,7 +581,7 @@ const pauseSelected = () => { toast.error('No eligible items to pause.') return } - if (true !== box.confirm(`Pause '${filtered.length}' selected items?`)) { + if (true !== (await box.confirm(`Pause '${filtered.length}' selected items?`))) { return false } filtered.forEach(id => socket.emit('item_pause', id)) diff --git a/ui/app/components/TaskForm.vue b/ui/app/components/TaskForm.vue index bffed254..96308e3b 100644 --- a/ui/app/components/TaskForm.vue +++ b/ui/app/components/TaskForm.vue @@ -409,7 +409,7 @@ const importItem = async (): Promise => { } if (form.url || form.timer) { - if (false === box.confirm('Overwrite the current form fields?', true)) { + if (false === (await box.confirm('Overwrite the current form fields?', true))) { return } } diff --git a/ui/app/composables/useConfirm.ts b/ui/app/composables/useConfirm.ts index 90ed293d..7286ca41 100644 --- a/ui/app/composables/useConfirm.ts +++ b/ui/app/composables/useConfirm.ts @@ -1,21 +1,48 @@ import { useStorage } from '@vueuse/core' +import { useDialog } from './useDialog' + +const dialog = useDialog() const reduceConfirm = useStorage('reduce_confirm', false) -function confirm(msg: string, force: boolean = false): boolean { +const confirm = async (msg: string, force: boolean = false) => { if (false === force && true === reduceConfirm.value) { return true } - return window.confirm(msg) + const { status } = await dialog.confirmDialog({ + title: 'Please Confirm', + message: msg, + cancelText: 'Cancel', + confirmText: 'OK', + }) + + return status } -function alert(msg: string): boolean { - return window.confirm(msg) +const alert = async (msg: string) => { + const { status } = await dialog.alertDialog({ + title: 'Alert', + message: msg, + confirmText: 'OK', + }) + return status } -function prompt(msg: string, defaultValue: string = ''): string | null { - return window.prompt(msg, defaultValue) +const prompt = async (msg: string, defaultValue: string = '') => { + const { status, value } = await dialog.promptDialog({ + title: 'Input Required', + message: msg, + initial: defaultValue, + cancelText: 'Cancel', + confirmText: 'OK', + }) + + if (status) { + return value + } + + return null } export default function useConfirm() { diff --git a/ui/app/pages/conditions.vue b/ui/app/pages/conditions.vue index afcbfa82..9dca9c90 100644 --- a/ui/app/pages/conditions.vue +++ b/ui/app/pages/conditions.vue @@ -222,7 +222,7 @@ const updateItems = async (newItems: ConditionItem[]): Promise => { } const deleteItem = async (cond: ConditionItem): Promise => { - if (!box.confirm(`Delete '${cond.name}'?`, true)) { + if (true !== (await box.confirm(`Delete '${cond.name}'?`, true))) { return } diff --git a/ui/app/pages/notifications.vue b/ui/app/pages/notifications.vue index bc234741..8855f943 100644 --- a/ui/app/pages/notifications.vue +++ b/ui/app/pages/notifications.vue @@ -312,7 +312,7 @@ const updateData = async (items: notification[]) => { } const deleteItem = async (item: notification) => { - if (true !== box.confirm(`Delete '${item.name}'?`)) { + if (true !== (await box.confirm(`Delete '${item.name}'?`))) { return } @@ -373,7 +373,7 @@ const join_events = (events: string[]) => !events || events.length < 1 ? 'ALL' : events.map(e => ucFirst(e)).join(', ') const sendTest = async () => { - if (true !== box.confirm('Send test notification?')) { + if (true !== (await box.confirm('Send test notification?'))) { return } diff --git a/ui/app/pages/presets.vue b/ui/app/pages/presets.vue index 28698370..a915e975 100644 --- a/ui/app/pages/presets.vue +++ b/ui/app/pages/presets.vue @@ -311,7 +311,7 @@ const updatePresets = async (items: Preset[]): Promise => { } const deleteItem = async (item: Preset) => { - if (true !== box.confirm(`Delete preset '${item.name}'?`, true)) { + if (true !== (await box.confirm(`Delete preset '${item.name}'?`, true))) { return } diff --git a/ui/app/pages/tasks.vue b/ui/app/pages/tasks.vue index be648b2f..bcc4bdf6 100644 --- a/ui/app/pages/tasks.vue +++ b/ui/app/pages/tasks.vue @@ -579,7 +579,7 @@ const deleteSelected = async () => { } const deleteItem = async (item: task_item) => { - if (true !== box.confirm(`Delete '${item.name}' task?`, true)) { + if (true !== (await box.confirm(`Delete '${item.name}' task?`, true))) { return } @@ -696,7 +696,7 @@ const runSelected = async () => { } const runNow = async (item: task_item, mass: boolean = false) => { - if (!mass && true !== box.confirm(`Run '${item.name}' now? it will also run at the scheduled time.`)) { + if (!mass && true !== (await box.confirm(`Run '${item.name}' now? it will also run at the scheduled time.`))) { return }