mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Remove TODOs
This commit is contained in:
@ -124,6 +124,7 @@ export {
|
||||
changeMainAPI,
|
||||
setGenerationProgress,
|
||||
updateChatMetadata,
|
||||
scrollChatToBottom,
|
||||
chat,
|
||||
this_chid,
|
||||
settings,
|
||||
|
@ -11,36 +11,11 @@ export {
|
||||
|
||||
const extensionNames = ['caption', 'dice', 'expressions', 'floating-prompt', 'memory'];
|
||||
const manifests = await getManifests(extensionNames);
|
||||
|
||||
// TODO: Delete in next release
|
||||
function migrateFromLocalStorage() {
|
||||
const extensions_urlKey = 'extensions_url';
|
||||
const extensions_autoConnectKey = 'extensions_autoconnect';
|
||||
const extensions_disabledKey = 'extensions_disabled';
|
||||
|
||||
const apiUrl = localStorage.getItem(extensions_urlKey);
|
||||
const autoConnect = localStorage.getItem(extensions_autoConnectKey);
|
||||
const extensionsDisabled = localStorage.getItem(extensions_disabledKey);
|
||||
|
||||
if (apiUrl !== null) {
|
||||
extension_settings.apiUrl = apiUrl;
|
||||
localStorage.removeItem(extensions_urlKey);
|
||||
}
|
||||
|
||||
if (autoConnect !== null) {
|
||||
extension_settings.autoConnect = autoConnect;
|
||||
localStorage.removeItem(extensions_autoConnectKey);
|
||||
}
|
||||
|
||||
if (extensionsDisabled !== null) {
|
||||
extension_settings.disabledExtensions = JSON.parse(extensionsDisabled);
|
||||
localStorage.removeItem(extensions_disabledKey);
|
||||
}
|
||||
}
|
||||
const defaultUrl = "http://localhost:5100";
|
||||
|
||||
const extension_settings = {
|
||||
apiUrl: '',
|
||||
autoConnect: '',
|
||||
apiUrl: defaultUrl,
|
||||
autoConnect: false,
|
||||
disabledExtensions: [],
|
||||
memory: {},
|
||||
note: {
|
||||
@ -56,7 +31,6 @@ let activeExtensions = new Set();
|
||||
|
||||
const getContext = () => window['TavernAI'].getContext();
|
||||
const getApiUrl = () => extension_settings.apiUrl;
|
||||
const defaultUrl = "http://localhost:5100";
|
||||
const defaultRequestArgs = { method: 'GET', headers: { 'Bypass-Tunnel-Reminder': 'bypass' } };
|
||||
let connectedToApi = false;
|
||||
|
||||
@ -274,8 +248,6 @@ function showExtensionsDetails() {
|
||||
}
|
||||
|
||||
function loadExtensionSettings(settings) {
|
||||
migrateFromLocalStorage();
|
||||
|
||||
if (settings.extension_settings) {
|
||||
Object.assign(extension_settings, settings.extension_settings);
|
||||
}
|
||||
|
@ -51,76 +51,7 @@ function onExtensionFloatingDefaultInput() {
|
||||
saveSettingsDebounced();
|
||||
}
|
||||
|
||||
// TODO Remove in next release
|
||||
function getLocalStorageKeys() {
|
||||
const context = getContext();
|
||||
|
||||
let keySuffix;
|
||||
|
||||
if (context.groupId) {
|
||||
keySuffix = context.groupId;
|
||||
}
|
||||
else if (context.characterId) {
|
||||
keySuffix = `${context.characters[context.characterId].name}_${context.chatId}`;
|
||||
}
|
||||
else {
|
||||
keySuffix = 'undefined';
|
||||
}
|
||||
|
||||
return {
|
||||
prompt: `extensions_floating_prompt_${keySuffix}`,
|
||||
interval: `extensions_floating_interval_${keySuffix}`,
|
||||
depth: `extensions_floating_depth_${keySuffix}`,
|
||||
position: `extensions_floating_position_${keySuffix}`,
|
||||
default: 'extensions_default_note',
|
||||
};
|
||||
}
|
||||
|
||||
function migrateFromLocalStorage() {
|
||||
const keys = getLocalStorageKeys();
|
||||
const defaultNote = localStorage.getItem(keys.default);
|
||||
const prompt = localStorage.getItem(keys.prompt);
|
||||
const interval = localStorage.getItem(keys.interval);
|
||||
const position = localStorage.getItem(keys.position);
|
||||
const depth = localStorage.getItem(keys.depth);
|
||||
|
||||
if (defaultNote !== null) {
|
||||
if (typeof extension_settings.note !== 'object') {
|
||||
extension_settings.note = {};
|
||||
}
|
||||
|
||||
extension_settings.note.default = defaultNote;
|
||||
saveSettingsDebounced();
|
||||
localStorage.removeItem(keys.default);
|
||||
}
|
||||
|
||||
if (chat_metadata) {
|
||||
if (interval !== null) {
|
||||
chat_metadata[metadata_keys.interval] = interval;
|
||||
localStorage.removeItem(keys.interval);
|
||||
}
|
||||
|
||||
if (depth !== null) {
|
||||
chat_metadata[metadata_keys.depth] = depth;
|
||||
localStorage.removeItem(keys.depth);
|
||||
}
|
||||
|
||||
if (position !== null) {
|
||||
chat_metadata[metadata_keys.position] = position;
|
||||
localStorage.removeItem(keys.position);
|
||||
}
|
||||
|
||||
if (prompt !== null) {
|
||||
chat_metadata[metadata_keys.prompt] = prompt;
|
||||
localStorage.removeItem(keys.prompt);
|
||||
saveChatDebounced();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function loadSettings() {
|
||||
migrateFromLocalStorage();
|
||||
chat_metadata[metadata_keys.prompt] = chat_metadata[metadata_keys.prompt] ?? extension_settings.note.default ?? '';
|
||||
chat_metadata[metadata_keys.interval] = chat_metadata[metadata_keys.interval] ?? DEFAULT_INTERVAL;
|
||||
chat_metadata[metadata_keys.position] = chat_metadata[metadata_keys.position] ?? DEFAULT_POSITION;
|
||||
|
@ -40,22 +40,7 @@ const defaultSettings = {
|
||||
memoryFrozen: false,
|
||||
};
|
||||
|
||||
// TODO Delete in next release
|
||||
function migrateFromLocalStorage() {
|
||||
const SETTINGS_KEY = 'extensions_memory_settings';
|
||||
const settings = localStorage.getItem(SETTINGS_KEY);
|
||||
|
||||
if (settings !== null) {
|
||||
const savedSettings = JSON.parse(settings);
|
||||
Object.assign(extension_settings.memory, savedSettings);
|
||||
localStorage.removeItem(SETTINGS_KEY);
|
||||
saveSettingsDebounced();
|
||||
}
|
||||
}
|
||||
|
||||
function loadSettings() {
|
||||
migrateFromLocalStorage();
|
||||
|
||||
if (Object.keys(extension_settings.memory).length === 0) {
|
||||
Object.assign(extension_settings.memory, defaultSettings);
|
||||
}
|
||||
|
@ -1,4 +1,10 @@
|
||||
import { saveSettingsDebounced, characters, callPopup, token } from "../script.js";
|
||||
import {
|
||||
saveSettingsDebounced,
|
||||
scrollChatToBottom,
|
||||
characters,
|
||||
callPopup,
|
||||
token,
|
||||
} from "../script.js";
|
||||
import { delay } from "./utils.js";
|
||||
|
||||
|
||||
@ -110,6 +116,7 @@ function switchWaifuMode() {
|
||||
const waifuMode = localStorage.getItem(storage_keys.waifuMode);
|
||||
power_user.waifuMode = waifuMode === null ? false : waifuMode == "true";
|
||||
$("body").toggleClass("waifuMode", power_user.waifuMode);
|
||||
scrollChatToBottom();
|
||||
}
|
||||
|
||||
function applyAvatarStyle() {
|
||||
@ -445,7 +452,7 @@ $(document).ready(() => {
|
||||
});
|
||||
|
||||
$("#ui-preset-save-button").on('click', async function () {
|
||||
const name = await callPopup('Name him, name your son:', 'input');
|
||||
const name = await callPopup('Enter a theme preset name:', 'input');
|
||||
|
||||
if (!name) {
|
||||
return;
|
||||
|
Reference in New Issue
Block a user