mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-03-28 17:43:05 +01:00
Add <Unread Count>+ as indicator unreads matching length of conversation fetch
This commit is contained in:
File diff suppressed because one or more lines are too long
1
frontend/dist/assets/index-CG0iOYhX.js.map
vendored
Normal file
1
frontend/dist/assets/index-CG0iOYhX.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
1
frontend/dist/assets/index-DkHyTtP0.js.map
vendored
1
frontend/dist/assets/index-DkHyTtP0.js.map
vendored
File diff suppressed because one or more lines are too long
2
frontend/dist/index.html
vendored
2
frontend/dist/index.html
vendored
@@ -13,7 +13,7 @@
|
||||
<link rel="shortcut icon" href="/favicon.ico" />
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
|
||||
<link rel="manifest" href="/site.webmanifest" />
|
||||
<script type="module" crossorigin src="/assets/index-DkHyTtP0.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-CG0iOYhX.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-DZ67iE5i.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -15,6 +15,9 @@ import type {
|
||||
|
||||
const API_BASE = '/api';
|
||||
|
||||
/** Max messages fetched per conversation for unread counting. If count equals this, there may be more. */
|
||||
export const UNREAD_FETCH_LIMIT = 100;
|
||||
|
||||
async function fetchJson<T>(url: string, options?: RequestInit): Promise<T> {
|
||||
const res = await fetch(`${API_BASE}${url}`, {
|
||||
...options,
|
||||
@@ -130,7 +133,7 @@ export const api = {
|
||||
},
|
||||
getMessagesBulk: (
|
||||
conversations: Array<{ type: 'PRIV' | 'CHAN'; conversation_key: string }>,
|
||||
limitPerConversation: number = 100
|
||||
limitPerConversation: number = UNREAD_FETCH_LIMIT
|
||||
) =>
|
||||
fetchJson<Record<string, Message[]>>(
|
||||
`/messages/bulk?limit_per_conversation=${limitPerConversation}`,
|
||||
|
||||
@@ -4,6 +4,7 @@ import { getStateKey, type ConversationTimes } from '../utils/conversationState'
|
||||
import { getPubkeyPrefix, getContactDisplayName } from '../utils/pubkey';
|
||||
import { ContactAvatar } from './ContactAvatar';
|
||||
import { CONTACT_TYPE_REPEATER } from '../utils/contactAvatar';
|
||||
import { UNREAD_FETCH_LIMIT } from '../api';
|
||||
import { Input } from './ui/input';
|
||||
import { Button } from './ui/button';
|
||||
import { cn } from '@/lib/utils';
|
||||
@@ -26,6 +27,11 @@ interface SidebarProps {
|
||||
onMarkAllRead: () => void;
|
||||
}
|
||||
|
||||
/** Format unread count, showing "X+" if at the fetch limit (indicating there may be more) */
|
||||
function formatUnreadCount(count: number): string {
|
||||
return count >= UNREAD_FETCH_LIMIT ? `${count}+` : `${count}`;
|
||||
}
|
||||
|
||||
// Load sort preference from localStorage (default to 'recent')
|
||||
function loadSortOrder(): SortOrder {
|
||||
try {
|
||||
@@ -333,7 +339,7 @@ export function Sidebar({
|
||||
: 'bg-primary text-primary-foreground'
|
||||
)}
|
||||
>
|
||||
{unreadCount}
|
||||
{formatUnreadCount(unreadCount)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
@@ -394,7 +400,7 @@ export function Sidebar({
|
||||
: 'bg-primary text-primary-foreground'
|
||||
)}
|
||||
>
|
||||
{unreadCount}
|
||||
{formatUnreadCount(unreadCount)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useState, useCallback, useEffect, useRef } from 'react';
|
||||
import { api } from '../api';
|
||||
import { api, UNREAD_FETCH_LIMIT } from '../api';
|
||||
import {
|
||||
getLastMessageTimes,
|
||||
setLastMessageTime,
|
||||
@@ -71,7 +71,7 @@ export function useUnreadCounts(
|
||||
if (conversations.length === 0) return;
|
||||
|
||||
try {
|
||||
const bulkMessages = await api.getMessagesBulk(conversations, 100);
|
||||
const bulkMessages = await api.getMessagesBulk(conversations, UNREAD_FETCH_LIMIT);
|
||||
const newUnreadCounts: Record<string, number> = {};
|
||||
const newMentions: Record<string, boolean> = {};
|
||||
const newLastMessageTimes: Record<string, number> = {};
|
||||
|
||||
Reference in New Issue
Block a user