mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-04-12 01:51:11 +02:00
Fix auto-load not triggering from hotswaps
This commit is contained in:
parent
5d1e27c820
commit
bab368e3d2
@ -33,12 +33,12 @@ import {
|
|||||||
} from "./power-user.js";
|
} from "./power-user.js";
|
||||||
|
|
||||||
import { LoadLocal, SaveLocal, CheckLocal, LoadLocalBool } from "./f-localStorage.js";
|
import { LoadLocal, SaveLocal, CheckLocal, LoadLocalBool } from "./f-localStorage.js";
|
||||||
import { selected_group, is_group_generating, getGroupAvatar, groups } from "./group-chats.js";
|
import { selected_group, is_group_generating, getGroupAvatar, groups, openGroupById } from "./group-chats.js";
|
||||||
import {
|
import {
|
||||||
SECRET_KEYS,
|
SECRET_KEYS,
|
||||||
secret_state,
|
secret_state,
|
||||||
} from "./secrets.js";
|
} from "./secrets.js";
|
||||||
import { sortByCssOrder, debounce, delay } from "./utils.js";
|
import { debounce, delay } from "./utils.js";
|
||||||
import { chat_completion_sources, oai_settings } from "./openai.js";
|
import { chat_completion_sources, oai_settings } from "./openai.js";
|
||||||
|
|
||||||
var NavToggle = document.getElementById("nav-toggle");
|
var NavToggle = document.getElementById("nav-toggle");
|
||||||
@ -354,10 +354,8 @@ async function RA_autoloadchat() {
|
|||||||
selectCharacterById(String(active_character_id));
|
selectCharacterById(String(active_character_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
let groupToAutoLoad = document.querySelector(`.group_select[grid="${active_group}"]`);
|
if (active_group != null) {
|
||||||
|
openGroupById(String(active_group));
|
||||||
if (groupToAutoLoad != null) {
|
|
||||||
$(groupToAutoLoad).click();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the character list hadn't been loaded yet, try again.
|
// if the character list hadn't been loaded yet, try again.
|
||||||
@ -395,17 +393,18 @@ export async function favsToHotswap() {
|
|||||||
slot.attr('grid', isGroup ? grid : '');
|
slot.attr('grid', isGroup ? grid : '');
|
||||||
slot.attr('chid', isCharacter ? chid : '');
|
slot.attr('chid', isCharacter ? chid : '');
|
||||||
slot.data('id', isGroup ? grid : chid);
|
slot.data('id', isGroup ? grid : chid);
|
||||||
slot.attr('title', '');
|
|
||||||
|
|
||||||
if (isGroup) {
|
if (isGroup) {
|
||||||
const group = groups.find(x => x.id === grid);
|
const group = groups.find(x => x.id === grid);
|
||||||
const avatar = getGroupAvatar(group);
|
const avatar = getGroupAvatar(group);
|
||||||
$(slot).find('img').replaceWith(avatar);
|
$(slot).find('img').replaceWith(avatar);
|
||||||
|
$(slot).attr('title', group.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isCharacter) {
|
if (isCharacter) {
|
||||||
const avatarUrl = getThumbnailUrl('avatar', entity.item.avatar);
|
const avatarUrl = getThumbnailUrl('avatar', entity.item.avatar);
|
||||||
$(slot).find('img').attr('src', avatarUrl);
|
$(slot).find('img').attr('src', avatarUrl);
|
||||||
|
$(slot).attr('title', entity.item.avatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
$(slot).css('cursor', 'pointer');
|
$(slot).css('cursor', 'pointer');
|
||||||
@ -933,14 +932,16 @@ $("document").ready(function () {
|
|||||||
|
|
||||||
// when a char is selected from the list, save their name as the auto-load character for next page load
|
// when a char is selected from the list, save their name as the auto-load character for next page load
|
||||||
$(document).on("click", ".character_select", function () {
|
$(document).on("click", ".character_select", function () {
|
||||||
setActiveCharacter($(this).find('.avatar').attr('title'));
|
const characterId = $(this).find('.avatar').attr('title') || $(this).attr('title');
|
||||||
|
setActiveCharacter(characterId);
|
||||||
setActiveGroup(null);
|
setActiveGroup(null);
|
||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on("click", ".group_select", function () {
|
$(document).on("click", ".group_select", function () {
|
||||||
|
const groupId = $(this).data('id') || $(this).attr('grid');
|
||||||
setActiveCharacter(null);
|
setActiveCharacter(null);
|
||||||
setActiveGroup($(this).data('id'));
|
setActiveGroup(groupId);
|
||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -308,6 +308,9 @@ async function getGroups() {
|
|||||||
|
|
||||||
// Convert groups to new format
|
// Convert groups to new format
|
||||||
for (const group of groups) {
|
for (const group of groups) {
|
||||||
|
if (typeof group.id === 'number') {
|
||||||
|
group.id = String(group.id);
|
||||||
|
}
|
||||||
if (group.disabled_members == undefined) {
|
if (group.disabled_members == undefined) {
|
||||||
group.disabled_members = [];
|
group.disabled_members = [];
|
||||||
}
|
}
|
||||||
|
@ -2659,7 +2659,7 @@ app.post('/creategroup', jsonParser, (request, response) => {
|
|||||||
return response.sendStatus(400);
|
return response.sendStatus(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
const id = Date.now();
|
const id = String(Date.now());
|
||||||
const groupMetadata = {
|
const groupMetadata = {
|
||||||
id: id,
|
id: id,
|
||||||
name: request.body.name ?? 'New Group',
|
name: request.body.name ?? 'New Group',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user