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