diff --git a/src/app.scss b/src/app.scss index 2d41614..5658593 100644 --- a/src/app.scss +++ b/src/app.scss @@ -117,6 +117,10 @@ html { min-height: 100vh; } +select option.is-default { + background-color: #0842e058; +} + .is-disabled { pointer-events: none; cursor: default; diff --git a/src/lib/ChatSettingField.svelte b/src/lib/ChatSettingField.svelte index 615308a..36a651d 100644 --- a/src/lib/ChatSettingField.svelte +++ b/src/lib/ChatSettingField.svelte @@ -2,9 +2,10 @@ import { createEventDispatcher } from 'svelte' import { getProfile } from './Profiles.svelte' import { addChat, cleanSettingValue, setChatSettingValue } from './Storage.svelte' - import type { Chat, ChatSetting, ChatSettings, SettingPrompt } from './Types.svelte' + import type { Chat, ChatSetting, ChatSettings, ControlAction, FieldControl, SettingPrompt } from './Types.svelte' import { autoGrowInputOnEvent } from './Util.svelte' import { replace } from 'svelte-spa-router' + import Fa from 'svelte-fa/src/fa.svelte' export let setting:ChatSetting export let chatSettings:ChatSettings @@ -14,6 +15,10 @@ const chatId = chat.id + const fieldControls:ControlAction[] = (setting.fieldControls || [] as FieldControl[]).map(fc => { + return fc.getAction(chatId, setting, chatSettings[setting.key]) + }) + if (originalProfile) { // eventually... } @@ -36,7 +41,8 @@ { prompt: 'Would you like to start a new chat session with this profile?', checkPrompt: (setting, newVal, oldVal) => { - return newVal !== oldVal + return chat.sessionStarted && newVal !== originalProfile && + (getProfile(newVal).characterName !== chatSettings.characterName) }, onYes: (setting, newVal, oldVal) => { // start new char session, apply this profile, amd start it @@ -46,6 +52,7 @@ replace(`/chat/${newChatId}`) return true }, + onNo: (setting, newVal, oldVal) => true, // Continue on no passed: false }, { @@ -54,6 +61,7 @@ return chat.sessionStarted && newVal !== originalProfile && (getProfile(newVal).characterName !== chatSettings.characterName) }, + onYes: (setting, newVal, oldVal) => true, passed: false } ] @@ -116,12 +124,14 @@ } } else { // roll-back - setChatSettingValue(chatId, setting, val) - // refresh setting modal, if open - c.onNo && c.onNo(setting, newVal, val) - refreshSettings() - resetSettingCheck(setting.key) - return + if (!c.onNo || !c.onNo(setting, newVal, val)) { + setChatSettingValue(chatId, setting, val) + // refresh setting modal, if open + c.onNo && c.onNo(setting, newVal, val) + refreshSettings() + resetSettingCheck(setting.key) + return + } } } else { c.passed = true @@ -172,7 +182,7 @@ {/if}