MCPcopy Create free account
hub / github.com/CommE2E/comm / updateBadgeCount

Method updateBadgeCount

native/push/push-handler.react.js:323–422  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

321 }
322
323 async updateBadgeCount() {
324 const curThinUnreadCounts = this.props.thinThreadsUnreadCount;
325 const curConnections = this.props.connection;
326
327 const currentUnreadThickThreads = this.props.unreadThickThreadIDs;
328 const isTunnelbrokerAuthorized =
329 this.props.tunnelbrokerSocketState.connected &&
330 this.props.tunnelbrokerSocketState.isAuthorized;
331
332 const currentFarcasterUnreadCount = this.props.farcasterUnreadCount;
333
334 const notifStorageUpdates: Array<{
335 +id: string,
336 +unreadCount: number,
337 }> = [];
338 const notifsStorageQueries: Array<string> = [];
339
340 for (const keyserverID in curThinUnreadCounts) {
341 if (curConnections[keyserverID]?.status !== 'connected') {
342 notifsStorageQueries.push(keyserverID);
343 continue;
344 }
345
346 notifStorageUpdates.push({
347 id: keyserverID,
348 unreadCount: curThinUnreadCounts[keyserverID],
349 });
350 }
351
352 let queriedKeyserverData: $ReadOnlyArray<{
353 +id: string,
354 +unreadCount: number,
355 }> = [];
356
357 const handleUnreadThickThreadIDsInNotifsStorage = (async () => {
358 if (isTunnelbrokerAuthorized) {
359 await commCoreModule.updateUnreadThickThreadsInNotifsStorage(
360 currentUnreadThickThreads,
361 );
362 return currentUnreadThickThreads;
363 }
364 return await commCoreModule.getUnreadThickThreadIDsFromNotifsStorage();
365 })();
366
367 const handleUnreadFarcasterInNotifsStorage = (async () => {
368 if (isTunnelbrokerAuthorized) {
369 const farcasterEntry = {
370 id: 'FARCASTER',
371 unreadCount: currentFarcasterUnreadCount,
372 };
373 await commCoreModule.updateDataInNotifStorage([farcasterEntry]);
374 return currentFarcasterUnreadCount;
375 }
376 const farcasterData = await commCoreModule.getDataFromNotifStorage([
377 'FARCASTER',
378 ]);
379 if (farcasterData.length > 0) {
380 return farcasterData[0].unreadCount;

Callers 2

componentDidMountMethod · 0.95
componentDidUpdateMethod · 0.95

Calls 7

pushMethod · 0.80
setBadgeMethod · 0.80
logMethod · 0.45

Tested by

no test coverage detected