From e30631be6024beb88862332db105074b0f79db6e Mon Sep 17 00:00:00 2001 From: eiiko6 Date: Fri, 16 Jan 2026 12:39:46 +0100 Subject: [PATCH] made room unread_count server-side --- package.json | 2 +- src/components/RoomList.vue | 25 ++++++++++++++++++------- src/types.ts | 1 + 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index c995a98..27dc9bf 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "frangipane-client", "private": true, "version": "0.1.0", - "backendVersion": "1.0.1", + "backendVersion": "1.0.2", "type": "module", "scripts": { "dev": "vite", diff --git a/src/components/RoomList.vue b/src/components/RoomList.vue index 92b9552..c6aed89 100644 --- a/src/components/RoomList.vue +++ b/src/components/RoomList.vue @@ -49,9 +49,20 @@ const showCreate = ref(false); const rooms = ref([]); const unreadCounts = ref>({}); - async function refreshRooms() { - rooms.value = await fetchRooms(); + const fetchedRooms = await fetchRooms(); + rooms.value = fetchedRooms; + + fetchedRooms.forEach(room => { + console.log(`Unread count for room ${room.name}: ${room.unread_count}`); + + // If the room isn't the currently active one, store the count + if (room.unread_count && route.params.uuid !== room.uuid) { + unreadCounts.value[room.uuid] = room.unread_count; + } else { + unreadCounts.value[room.uuid] = 0; + } + }); } const incrementUnread = (roomUuid: string) => { @@ -74,7 +85,8 @@ watch( ); onMounted(async () => { - rooms.value = await fetchRooms(); + // rooms.value = await fetchRooms(); + await refreshRooms() }); @@ -128,18 +140,17 @@ onMounted(async () => { .unread-badge { background-color: var(--accent); - color: white; + color: black; font-size: 0.75rem; font-weight: bold; min-width: 20px; height: 20px; - border-radius: 10px; + border-radius: 50%; display: flex; align-items: center; justify-content: center; - padding: 0 6px; + padding: 0; margin-left: 8px; - box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); } .rooms-header { diff --git a/src/types.ts b/src/types.ts index a8679de..cfb52f5 100644 --- a/src/types.ts +++ b/src/types.ts @@ -23,6 +23,7 @@ export interface Room { owner_uuid: string name: string global: boolean + unread_count: number } export interface Message {