Fix array slicing, decrease default recent display to 3
| @@ -30,7 +30,7 @@ import { sortMoments, timestampToMoment } from './utils.js'; | ||
| 30 | 30 | const assistantAvatarKey = 'assistant'; |
| 31 | 31 | const defaultAssistantAvatar = 'default_Assistant.png'; |
| 32 | 32 | |
| 33 | 33 | const DEFAULT_DISPLAYED = 53; |
| 34 | 34 | const MAX_DISPLAYED = 20; |
| 35 | 35 | |
| 36 | 36 | export function getPermanentAssistantAvatar() { |
| @@ -272,7 +272,6 @@ async function getRecentChats() { | ||
| 272 | 272 | data.sort((a, b) => sortMoments(timestampToMoment(a.last_mes), timestampToMoment(b.last_mes))) |
| 273 | 273 | .map(chat => ({ chat, character: characters.find(x => x.avatar === chat.avatar), group: groups.find(x => x.id === chat.group) })) |
| 274 | 274 | .filter(t => t.character || t.group) |
| 275 | - .slice(0, MAX_DISPLAYED) | |
| 276 | 275 | .forEach(({ chat, character, group }, index) => { |
| 277 | 276 | const chatTimestamp = timestampToMoment(chat.last_mes); |
| 278 | 277 | chat.char_name = character?.name || group?.name || ''; |
| @@ -282,9 +281,11 @@ async function getRecentChats() { | ||
| 282 | 281 | chat.char_thumbnail = character ? getThumbnailUrl('avatar', character.avatar) : system_avatar; |
| 283 | 282 | chat.is_group = !!group; |
| 284 | 283 | chat.hidden = index >= DEFAULT_DISPLAYED; |
| 284 | + chat.avatar = chat.avatar || ''; | |
| 285 | + chat.group = chat.group || ''; | |
| 285 | 286 | }); |
| 286 | 287 | |
| 287 | 288 | return data.slice(0, MAX_DISPLAYED); |
| 288 | 289 | } |
| 289 | 290 | |
| 290 | 291 | export async function openPermanentAssistantChat({ tryCreate = true, created = false } = {}) { |