Added detection for broken/deleted bookmark links, can expand on this to automatically delete broken links, but for now it just hides the icon.

This commit is contained in:
based
2023-08-20 02:45:20 +10:00
parent b56fe3e01b
commit dba685bffb
2 changed files with 25 additions and 1 deletions

View File

@ -55,6 +55,7 @@ import {
renameGroupChat, renameGroupChat,
importGroupChat, importGroupChat,
getGroupBlock, getGroupBlock,
getGroupChatNames,
} from "./scripts/group-chats.js"; } from "./scripts/group-chats.js";
import { import {
@ -1604,8 +1605,17 @@ function addOneMessage(mes, { type = "normal", insertAfter = null, scroll = true
mes.is_user, mes.is_user,
); );
const bias = messageFormatting(mes.extra?.bias ?? ""); const bias = messageFormatting(mes.extra?.bias ?? "");
const bookmarkLink = mes?.extra?.bookmark_link ?? ''; let bookmarkLink = mes?.extra?.bookmark_link ?? '';
// Verify bookmarked chat still exists
if (bookmarkLink !== '' ) {
let chat_names = selected_group
? getGroupChatNames(selected_group)
: Object.values(getPastCharacterChats()).map(({file_name}) => file_name);
if (!chat_names.includes(bookmarkLink)) {
bookmarkLink = ''
}
}
let params = { let params = {
mesId: count_view_mes, mesId: count_view_mes,
characterName: characterName, characterName: characterName,

View File

@ -80,6 +80,7 @@ export {
regenerateGroup, regenerateGroup,
resetSelectedGroup, resetSelectedGroup,
select_group_chats, select_group_chats,
getGroupChatNames,
} }
let is_group_generating = false; // Group generation flag let is_group_generating = false; // Group generation flag
@ -405,6 +406,19 @@ function getGroupAvatar(group) {
return groupAvatar; return groupAvatar;
} }
function getGroupChatNames(groupId) {
const group = groups.find(x => x.id === groupId);
if (!group) {
return [];
}
const names = [];
for (const chatId of group.chats) {
names.push(chatId);
}
return names;
}
async function generateGroupWrapper(by_auto_mode, type = null, params = {}) { async function generateGroupWrapper(by_auto_mode, type = null, params = {}) {
if (online_status === "no_connection") { if (online_status === "no_connection") {