()
| 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; |
no test coverage detected