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:
valadaptive 2023-12-09 18:41:51 -05:00
parent 0ea0399ed1
commit babb127aee
1 changed files with 34 additions and 34 deletions

View File

@ -968,6 +968,22 @@ async function getStatusTextgen() {
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() {
$('.api_loading').show();
$('.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) {
const displayModes = {
'rm_group_chats_block': 'flex',
@ -8348,6 +8348,24 @@ jQuery(async function () {
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 menu = $('#options');
@ -9034,24 +9052,6 @@ jQuery(async function () {
});
//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_button').click(function () {
$('#character_import_file').click();