mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-05-05 04:52:59 +02:00
Fix new-message unread-count dedupe
This commit is contained in:
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-Cp9RQ4Uj.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-CvVcf00q.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-DaLCXB8p.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -34,6 +34,8 @@ const MAX_RAW_PACKETS = 500;
|
||||
export function App() {
|
||||
const messageInputRef = useRef<MessageInputHandle>(null);
|
||||
const activeConversationRef = useRef<Conversation | null>(null);
|
||||
// Track seen message IDs to prevent duplicate unread increments
|
||||
const seenMessageIdsRef = useRef<Set<number>>(new Set());
|
||||
const [health, setHealth] = useState<HealthStatus | null>(null);
|
||||
const [config, setConfig] = useState<RadioConfig | null>(null);
|
||||
const [appSettings, setAppSettings] = useState<AppSettings | null>(null);
|
||||
@@ -129,8 +131,20 @@ export function App() {
|
||||
// Track for unread counts and sorting
|
||||
trackNewMessage(msg);
|
||||
|
||||
// Count unread for non-active, incoming messages
|
||||
// Count unread for non-active, incoming messages (with deduplication)
|
||||
if (!msg.outgoing && !isForActiveConversation) {
|
||||
// Skip if we've already seen this message ID (prevents duplicate increments)
|
||||
if (seenMessageIdsRef.current.has(msg.id)) {
|
||||
return;
|
||||
}
|
||||
seenMessageIdsRef.current.add(msg.id);
|
||||
|
||||
// Limit set size to prevent memory issues
|
||||
if (seenMessageIdsRef.current.size > 1000) {
|
||||
const ids = Array.from(seenMessageIdsRef.current);
|
||||
seenMessageIdsRef.current = new Set(ids.slice(-500));
|
||||
}
|
||||
|
||||
let stateKey: string | null = null;
|
||||
if (msg.type === 'CHAN' && msg.conversation_key) {
|
||||
stateKey = getStateKey('channel', msg.conversation_key);
|
||||
|
||||
Reference in New Issue
Block a user