mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-05-08 22:35:10 +02:00
Fetch all contacts to FE to prevent subsequent fetches on contact data
This commit is contained in:
+12
-3
@@ -45,12 +45,21 @@ async def websocket_endpoint(websocket: WebSocket) -> None:
|
||||
}
|
||||
await ws_manager.send_personal(websocket, "health", health_data)
|
||||
|
||||
# Contacts
|
||||
contacts = await ContactRepository.get_all(limit=500)
|
||||
# Contacts - fetch all by paginating until exhausted
|
||||
all_contacts = []
|
||||
chunk_size = 500
|
||||
offset = 0
|
||||
while True:
|
||||
chunk = await ContactRepository.get_all(limit=chunk_size, offset=offset)
|
||||
all_contacts.extend(chunk)
|
||||
if len(chunk) < chunk_size:
|
||||
break
|
||||
offset += chunk_size
|
||||
|
||||
await ws_manager.send_personal(
|
||||
websocket,
|
||||
"contacts",
|
||||
[c.model_dump() for c in contacts],
|
||||
[c.model_dump() for c in all_contacts],
|
||||
)
|
||||
|
||||
# Channels
|
||||
|
||||
+542
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
-542
File diff suppressed because one or more lines are too long
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -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-DviEalHS.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-BeFZihz7.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-CnRBRJ10.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -71,7 +71,15 @@ export function useUnreadCounts(
|
||||
if (conversations.length === 0) return;
|
||||
|
||||
try {
|
||||
const bulkMessages = await api.getMessagesBulk(conversations, UNREAD_FETCH_LIMIT);
|
||||
// Fetch messages in chunks to avoid huge single requests
|
||||
const chunkSize = 200;
|
||||
const bulkMessages: Record<string, Message[]> = {};
|
||||
|
||||
for (let i = 0; i < conversations.length; i += chunkSize) {
|
||||
const chunk = conversations.slice(i, i + chunkSize);
|
||||
const chunkResult = await api.getMessagesBulk(chunk, UNREAD_FETCH_LIMIT);
|
||||
Object.assign(bulkMessages, chunkResult);
|
||||
}
|
||||
const newUnreadCounts: Record<string, number> = {};
|
||||
const newMentions: Record<string, boolean> = {};
|
||||
const newLastMessageTimes: Record<string, number> = {};
|
||||
|
||||
Reference in New Issue
Block a user