mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Move NovelAI status functions over to the rest
Have all the get(...)Status and event handler registrations in the same areas, rather than having the NovelAI ones far away. I want to eventually move all the API-specific stuff into separate modules, but this will make things cleaner for the time being.
This commit is contained in:
@@ -968,6 +968,22 @@ async function getStatusTextgen() {
|
|||||||
return resultCheckStatus();
|
return resultCheckStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getStatusNovel() {
|
||||||
|
try {
|
||||||
|
const result = await loadNovelSubscriptionData();
|
||||||
|
|
||||||
|
if (!result) {
|
||||||
|
throw new Error('Could not load subscription data');
|
||||||
|
}
|
||||||
|
|
||||||
|
online_status = getNovelTier();
|
||||||
|
} catch {
|
||||||
|
online_status = 'no_connection';
|
||||||
|
}
|
||||||
|
|
||||||
|
resultCheckStatus();
|
||||||
|
}
|
||||||
|
|
||||||
export function startStatusLoading() {
|
export function startStatusLoading() {
|
||||||
$('.api_loading').show();
|
$('.api_loading').show();
|
||||||
$('.api_button').addClass('disabled');
|
$('.api_button').addClass('disabled');
|
||||||
@@ -6072,22 +6088,6 @@ export async function displayPastChats() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getStatusNovel() {
|
|
||||||
try {
|
|
||||||
const result = await loadNovelSubscriptionData();
|
|
||||||
|
|
||||||
if (!result) {
|
|
||||||
throw new Error('Could not load subscription data');
|
|
||||||
}
|
|
||||||
|
|
||||||
online_status = getNovelTier();
|
|
||||||
} catch {
|
|
||||||
online_status = 'no_connection';
|
|
||||||
}
|
|
||||||
|
|
||||||
resultCheckStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
function selectRightMenuWithAnimation(selectedMenuId) {
|
function selectRightMenuWithAnimation(selectedMenuId) {
|
||||||
const displayModes = {
|
const displayModes = {
|
||||||
'rm_group_chats_block': 'flex',
|
'rm_group_chats_block': 'flex',
|
||||||
@@ -8348,6 +8348,24 @@ jQuery(async function () {
|
|||||||
getStatusTextgen();
|
getStatusTextgen();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#api_button_novel').on('click', async function (e) {
|
||||||
|
e.stopPropagation();
|
||||||
|
const api_key_novel = String($('#api_key_novel').val()).trim();
|
||||||
|
|
||||||
|
if (api_key_novel.length) {
|
||||||
|
await writeSecret(SECRET_KEYS.NOVEL, api_key_novel);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!secret_state[SECRET_KEYS.NOVEL]) {
|
||||||
|
console.log('No secret key saved for NovelAI');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
startStatusLoading();
|
||||||
|
// Check near immediately rather than waiting for up to 90s
|
||||||
|
await getStatusNovel();
|
||||||
|
});
|
||||||
|
|
||||||
var button = $('#options_button');
|
var button = $('#options_button');
|
||||||
var menu = $('#options');
|
var menu = $('#options');
|
||||||
|
|
||||||
@@ -9034,24 +9052,6 @@ jQuery(async function () {
|
|||||||
});
|
});
|
||||||
//Select chat
|
//Select chat
|
||||||
|
|
||||||
$('#api_button_novel').on('click', async function (e) {
|
|
||||||
e.stopPropagation();
|
|
||||||
const api_key_novel = String($('#api_key_novel').val()).trim();
|
|
||||||
|
|
||||||
if (api_key_novel.length) {
|
|
||||||
await writeSecret(SECRET_KEYS.NOVEL, api_key_novel);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!secret_state[SECRET_KEYS.NOVEL]) {
|
|
||||||
console.log('No secret key saved for NovelAI');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
startStatusLoading();
|
|
||||||
// Check near immediately rather than waiting for up to 90s
|
|
||||||
await getStatusNovel();
|
|
||||||
});
|
|
||||||
|
|
||||||
//**************************CHARACTER IMPORT EXPORT*************************//
|
//**************************CHARACTER IMPORT EXPORT*************************//
|
||||||
$('#character_import_button').click(function () {
|
$('#character_import_button').click(function () {
|
||||||
$('#character_import_file').click();
|
$('#character_import_file').click();
|
||||||
|
Reference in New Issue
Block a user