mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Migrate auto-connect and auto-load from localStorage
This commit is contained in:
@@ -47,8 +47,6 @@ var LeftNavPanel = document.getElementById('left-nav-panel');
|
||||
var WorldInfo = document.getElementById('WorldInfo');
|
||||
|
||||
var SelectedCharacterTab = document.getElementById('rm_button_selected_ch');
|
||||
var AutoConnectCheckbox = document.getElementById('auto-connect-checkbox');
|
||||
var AutoLoadChatCheckbox = document.getElementById('auto-load-chat-checkbox');
|
||||
|
||||
var connection_made = false;
|
||||
var retry_delay = 500;
|
||||
@@ -368,7 +366,7 @@ function RA_autoconnect(PrevApi) {
|
||||
setTimeout(RA_autoconnect, 100);
|
||||
return;
|
||||
}
|
||||
if (online_status === 'no_connection' && LoadLocalBool('AutoConnectEnabled')) {
|
||||
if (online_status === 'no_connection' && power_user.auto_connect) {
|
||||
switch (main_api) {
|
||||
case 'kobold':
|
||||
if (api_server && isValidUrl(api_server)) {
|
||||
@@ -719,21 +717,19 @@ export function initRossMods() {
|
||||
RA_checkOnlineStatus();
|
||||
}, 100);
|
||||
|
||||
// read the state of AutoConnect and AutoLoadChat.
|
||||
$(AutoConnectCheckbox).prop('checked', LoadLocalBool('AutoConnectEnabled'));
|
||||
$(AutoLoadChatCheckbox).prop('checked', LoadLocalBool('AutoLoadChatEnabled'));
|
||||
if (power_user.auto_load_chat) {
|
||||
RA_autoloadchat();
|
||||
}
|
||||
|
||||
setTimeout(function () {
|
||||
if (LoadLocalBool('AutoLoadChatEnabled') == true) { RA_autoloadchat(); }
|
||||
}, 200);
|
||||
if (power_user.auto_connect) {
|
||||
RA_autoconnect();
|
||||
}
|
||||
|
||||
|
||||
//Autoconnect on page load if enabled, or when api type is changed
|
||||
if (LoadLocalBool('AutoConnectEnabled') == true) { RA_autoconnect(); }
|
||||
$('#main_api').change(function () {
|
||||
var PrevAPI = main_api;
|
||||
setTimeout(() => RA_autoconnect(PrevAPI), 100);
|
||||
});
|
||||
|
||||
$('#api_button').click(function () { setTimeout(RA_checkOnlineStatus, 100); });
|
||||
|
||||
//toggle pin class when lock toggle clicked
|
||||
@@ -855,10 +851,6 @@ export function initRossMods() {
|
||||
OpenNavPanels();
|
||||
}, 300);
|
||||
|
||||
//save AutoConnect and AutoLoadChat prefs
|
||||
$(AutoConnectCheckbox).on('change', function () { SaveLocal('AutoConnectEnabled', $(AutoConnectCheckbox).prop('checked')); });
|
||||
$(AutoLoadChatCheckbox).on('change', function () { SaveLocal('AutoLoadChatEnabled', $(AutoLoadChatCheckbox).prop('checked')); });
|
||||
|
||||
$(SelectedCharacterTab).click(function () { SaveLocal('SelectedNavTab', 'rm_button_selected_ch'); });
|
||||
$('#rm_button_characters').click(function () { SaveLocal('SelectedNavTab', 'rm_button_characters'); });
|
||||
|
||||
|
Reference in New Issue
Block a user