refactor: Optimize current character initialization in stores.ts
This commit is contained in:
@@ -26,10 +26,6 @@ export const botMakerMode = writable(false)
|
|||||||
|
|
||||||
//optimization
|
//optimization
|
||||||
|
|
||||||
let db = get(DataBase)
|
|
||||||
let currentChar = get(selectedCharID)
|
|
||||||
let currentCharacter = db.characters ? (db.characters[currentChar]) : null
|
|
||||||
let currentChat = currentCharacter ? (currentCharacter.chats[currentCharacter.chatPage]) : null
|
|
||||||
export const CurrentCharacter = writable(null) as Writable<character | groupChat>
|
export const CurrentCharacter = writable(null) as Writable<character | groupChat>
|
||||||
export const CurrentSimpleCharacter = writable(null) as Writable<simpleCharacterArgument>
|
export const CurrentSimpleCharacter = writable(null) as Writable<simpleCharacterArgument>
|
||||||
export const CurrentChat = writable(null) as Writable<Chat>
|
export const CurrentChat = writable(null) as Writable<Chat>
|
||||||
@@ -37,6 +33,10 @@ export const CurrentUsername = writable('') as Writable<string>
|
|||||||
export const CurrentUserIcon = writable('') as Writable<string>
|
export const CurrentUserIcon = writable('') as Writable<string>
|
||||||
export const CurrentShowMemoryLimit = writable(false) as Writable<boolean>
|
export const CurrentShowMemoryLimit = writable(false) as Writable<boolean>
|
||||||
try {
|
try {
|
||||||
|
let db = get(DataBase)
|
||||||
|
let currentChar = get(selectedCharID)
|
||||||
|
let currentCharacter = db.characters ? (db.characters[currentChar]) : null
|
||||||
|
let currentChat = currentCharacter ? (currentCharacter.chats[currentCharacter.chatPage]) : null
|
||||||
CurrentCharacter.set(structuredClone(currentCharacter))
|
CurrentCharacter.set(structuredClone(currentCharacter))
|
||||||
CurrentSimpleCharacter.set(createSimpleCharacter(currentCharacter))
|
CurrentSimpleCharacter.set(createSimpleCharacter(currentCharacter))
|
||||||
CurrentChat.set(structuredClone(currentChat))
|
CurrentChat.set(structuredClone(currentChat))
|
||||||
|
|||||||
Reference in New Issue
Block a user