made room unread_count server-side
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
"name": "frangipane-client",
|
"name": "frangipane-client",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"backendVersion": "1.0.1",
|
"backendVersion": "1.0.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
@@ -49,9 +49,20 @@ const showCreate = ref(false);
|
|||||||
const rooms = ref<Room[]>([]);
|
const rooms = ref<Room[]>([]);
|
||||||
const unreadCounts = ref<Record<string, number>>({});
|
const unreadCounts = ref<Record<string, number>>({});
|
||||||
|
|
||||||
|
|
||||||
async function refreshRooms() {
|
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) => {
|
const incrementUnread = (roomUuid: string) => {
|
||||||
@@ -74,7 +85,8 @@ watch(
|
|||||||
);
|
);
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
rooms.value = await fetchRooms();
|
// rooms.value = await fetchRooms();
|
||||||
|
await refreshRooms()
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -128,18 +140,17 @@ onMounted(async () => {
|
|||||||
|
|
||||||
.unread-badge {
|
.unread-badge {
|
||||||
background-color: var(--accent);
|
background-color: var(--accent);
|
||||||
color: white;
|
color: black;
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
min-width: 20px;
|
min-width: 20px;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
border-radius: 10px;
|
border-radius: 50%;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding: 0 6px;
|
padding: 0;
|
||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.rooms-header {
|
.rooms-header {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export interface Room {
|
|||||||
owner_uuid: string
|
owner_uuid: string
|
||||||
name: string
|
name: string
|
||||||
global: boolean
|
global: boolean
|
||||||
|
unread_count: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Message {
|
export interface Message {
|
||||||
|
|||||||
Reference in New Issue
Block a user