diff --git a/public/scripts/RossAscends-mods.js b/public/scripts/RossAscends-mods.js index 6d7ac3d75..3a2d0a395 100644 --- a/public/scripts/RossAscends-mods.js +++ b/public/scripts/RossAscends-mods.js @@ -33,12 +33,12 @@ import { } from "./power-user.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 { SECRET_KEYS, secret_state, } 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"; var NavToggle = document.getElementById("nav-toggle"); @@ -354,10 +354,8 @@ async function RA_autoloadchat() { selectCharacterById(String(active_character_id)); } - let groupToAutoLoad = document.querySelector(`.group_select[grid="${active_group}"]`); - - if (groupToAutoLoad != null) { - $(groupToAutoLoad).click(); + if (active_group != null) { + openGroupById(String(active_group)); } // 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('chid', isCharacter ? chid : ''); slot.data('id', isGroup ? grid : chid); - slot.attr('title', ''); if (isGroup) { const group = groups.find(x => x.id === grid); const avatar = getGroupAvatar(group); $(slot).find('img').replaceWith(avatar); + $(slot).attr('title', group.name); } if (isCharacter) { const avatarUrl = getThumbnailUrl('avatar', entity.item.avatar); $(slot).find('img').attr('src', avatarUrl); + $(slot).attr('title', entity.item.avatar); } $(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 $(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); saveSettingsDebounced(); }); $(document).on("click", ".group_select", function () { + const groupId = $(this).data('id') || $(this).attr('grid'); setActiveCharacter(null); - setActiveGroup($(this).data('id')); + setActiveGroup(groupId); saveSettingsDebounced(); }); diff --git a/public/scripts/group-chats.js b/public/scripts/group-chats.js index e94b3c1f4..df4935eb3 100644 --- a/public/scripts/group-chats.js +++ b/public/scripts/group-chats.js @@ -308,6 +308,9 @@ async function getGroups() { // Convert groups to new format for (const group of groups) { + if (typeof group.id === 'number') { + group.id = String(group.id); + } if (group.disabled_members == undefined) { group.disabled_members = []; } diff --git a/server.js b/server.js index 4dfa9d741..68940201c 100644 --- a/server.js +++ b/server.js @@ -2659,7 +2659,7 @@ app.post('/creategroup', jsonParser, (request, response) => { return response.sendStatus(400); } - const id = Date.now(); + const id = String(Date.now()); const groupMetadata = { id: id, name: request.body.name ?? 'New Group',