diff --git a/src/lib/ChatScreens/Chat.svelte b/src/lib/ChatScreens/Chat.svelte index ce4d14ec..74fc1b33 100644 --- a/src/lib/ChatScreens/Chat.svelte +++ b/src/lib/ChatScreens/Chat.svelte @@ -93,11 +93,19 @@ } function getCbsCondition(){ - const cbsConditions:CbsConditions = { - firstmsg: firstMessage ?? false, - chatRole: DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage]?.message?.[idx]?.role ?? null, + try{ + const cbsConditions:CbsConditions = { + firstmsg: firstMessage ?? false, + chatRole: DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage]?.message?.[idx]?.role ?? null, + } + return cbsConditions + } + catch(e){ + return { + firstmsg: firstMessage ?? false, + chatRole: null, + } } - return cbsConditions } function displaya(message:string){