From cb5e0c4f5f713b1a205fe211ce5ef124c7e30d23 Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Mon, 14 Oct 2024 19:46:51 -0300 Subject: [PATCH] Let recent emojis as maximum 6 --- src/lib/state/ui/index.ts | 8 ++++---- src/routes/chat/+page.svelte | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/lib/state/ui/index.ts b/src/lib/state/ui/index.ts index a8a24a41c..53f9aa540 100644 --- a/src/lib/state/ui/index.ts +++ b/src/lib/state/ui/index.ts @@ -200,12 +200,12 @@ class Store { }) } - getMostUsed(top?: number) { - top = top ? top : 5 + getMostUsed(top = 6) { return derived(this.state.emojiCounter, counter => { return Object.entries(counter) - .sort((f, s) => s[1] - f[1]) - .map(v => v[0]) + .sort(([, countA], [, countB]) => countB - countA) + .slice(0, top) + .map(([emoji]) => emoji) }) } } diff --git a/src/routes/chat/+page.svelte b/src/routes/chat/+page.svelte index adcfddcf9..66fca3981 100644 --- a/src/routes/chat/+page.svelte +++ b/src/routes/chat/+page.svelte @@ -71,8 +71,7 @@ // TODO(Lucas): Need to improve that for chats when not necessary all users are friends $: loading = get(UIStore.state.chats).length > 0 && !$activeChat.users.slice(1).some(userId => $users[userId]?.name !== undefined) - $: chatName = $activeChat.kind === ChatType.DirectMessage ? $users[$activeChat.users[1]]?.name : ($activeChat.name ?? $users[$activeChat.users[1]]?.name) - $: chatName = $activeChat.kind === ChatType.DirectMessage ? $users[$activeChat.users[1]]?.name : ($activeChat.name ?? $users[$activeChat.users[1]]?.name) + $: chatName = $activeChat.kind === ChatType.DirectMessage ? $users[$activeChat.users[1]]?.name : $activeChat.name ?? $users[$activeChat.users[1]]?.name $: statusMessage = $activeChat.kind === ChatType.DirectMessage ? $users[$activeChat.users[1]]?.profile?.status_message : $activeChat.motd $: pinned = getPinned($conversation)