From 8ce869c717c64f3091c31b060a78a51fee0f78bf Mon Sep 17 00:00:00 2001 From: Webifi Date: Sat, 27 May 2023 12:29:39 -0500 Subject: [PATCH] Roll-back to using confirm/alert for consistency --- src/lib/Chat.svelte | 86 ++++++--------------------------------------- 1 file changed, 11 insertions(+), 75 deletions(-) diff --git a/src/lib/Chat.svelte b/src/lib/Chat.svelte index 6fe6ff0..14ab1e8 100644 --- a/src/lib/Chat.svelte +++ b/src/lib/Chat.svelte @@ -143,23 +143,6 @@ setTimeout(() => document.querySelector('.chat-focus-point')?.scrollIntoView({ behavior: 'smooth', block: 'end' }), 0) } - // Show question modal - // Yeah, probably should make a component, but... - let qYesNo = (v) => {} - let question:any = null - const askQuestion = (title, message, yesFn, noFn, cls?) => { - qYesNo = (v) => { question = null; v ? yesFn() : noFn() } - question = [title, message, cls] - } - - // Show notice modal - let nDone = (v) => {} - let notice:any = null - const doNotice = (title, message, doneFn, cls?) => { - nDone = (v) => { notice = null; doneFn() } - notice = [title, message, cls] - } - // Send API request const sendRequest = async (messages: Message[], doingSummary?:boolean, withSummary?:boolean): Promise => { // Show updating bar @@ -556,13 +539,13 @@ (typeof setting.afterChange === 'function') && setting.afterChange(chatId, setting) && showSettingsModal++ } if (setting.key === 'profile' && checkSessionActivity(chatId)) { - askQuestion( - 'Warning', - 'Switching profiles will clear your current chat session. Are you sure you want to continue?', - () => { doSet() }, // Yes - () => { el.value = getChatSettingValue(chatId, setting) }, // No - 'is-warning' - ) + if (window.confirm('Switching profiles will clear your current chat session. Are you sure you want to continue?')) { + // Switch profiles + () => { doSet() } + } else { + // Roll-back + () => { el.value = getChatSettingValue(chatId, setting) } + } } else { debounce[setting.key] = setTimeout(doSet, 250) } @@ -584,7 +567,7 @@ try { saveCustomProfile(chat.settings) } catch (e) { - doNotice('Error saving profile', e.message, () => {}, 'is-danger') + alert('Error saving profile: ' + e.message) } } @@ -614,7 +597,7 @@ updateProfileSelectOptions() showSettingsModal && showSettingsModal++ } catch (e) { - doNotice('Error cloning profile', e.message, () => {}, 'is-danger') + alert('Error cloning profile: ' + e.message) } } @@ -629,7 +612,7 @@ updateProfileSelectOptions() showSettings() } catch (e) { - doNotice('Error deleting profile', e.message, () => {}, 'is-danger') + alert('Error deleting profile: ' + e.message) } } @@ -652,7 +635,7 @@ updateProfileSelectOptions() showSettingsModal && showSettingsModal++ } catch (e) { - doNotice('Unable to import profile', e.message, () => {}, 'is-danger') + alert('Unable to import profile: ' + e.message) } } } @@ -871,53 +854,6 @@ - - - - - - - - - -