From 560f4592e7c8d098ed802d9fcf30fd283ad99af9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Mon, 1 Aug 2022 18:31:49 +0200 Subject: [PATCH] Stream marker updates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- app/soapbox/actions/streaming.ts | 4 ++++ app/soapbox/components/helmet.tsx | 11 ++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/soapbox/actions/streaming.ts b/app/soapbox/actions/streaming.ts index c77daa6ac..dcb190f25 100644 --- a/app/soapbox/actions/streaming.ts +++ b/app/soapbox/actions/streaming.ts @@ -11,6 +11,7 @@ import { } from './announcements'; import { updateConversations } from './conversations'; import { fetchFilters } from './filters'; +import { MARKER_FETCH_SUCCESS } from './markers'; import { updateNotificationsQueue, expandNotifications } from './notifications'; import { updateStatus } from './statuses'; import { @@ -115,6 +116,9 @@ const connectTimelineStream = ( case 'announcement.delete': dispatch(deleteAnnouncement(data.payload)); break; + case 'marker': + dispatch({ type: MARKER_FETCH_SUCCESS, marker: JSON.parse(data.payload) }); + break; } }, }; diff --git a/app/soapbox/components/helmet.tsx b/app/soapbox/components/helmet.tsx index 81383ad08..cd13dd30a 100644 --- a/app/soapbox/components/helmet.tsx +++ b/app/soapbox/components/helmet.tsx @@ -2,15 +2,16 @@ import * as React from 'react'; import { Helmet as ReactHelmet } from 'react-helmet'; import { useAppSelector, useSettings } from 'soapbox/hooks'; +import { RootState } from 'soapbox/store'; import FaviconService from 'soapbox/utils/favicon_service'; FaviconService.initFaviconService(); -const getNotifTotals = (state: any): number => { - const notifications = state.getIn(['notifications', 'unread'], 0); - const chats = state.getIn(['chats', 'items']).reduce((acc: any, curr: any) => acc + Math.min(curr.get('unread', 0), 1), 0); - const reports = state.getIn(['admin', 'openReports']).count(); - const approvals = state.getIn(['admin', 'awaitingApproval']).count(); +const getNotifTotals = (state: RootState): number => { + const notifications = state.notifications.unread || 0; + const chats = state.chats.items.reduce((acc: any, curr: any) => acc + Math.min(curr.get('unread', 0), 1), 0); + const reports = state.admin.openReports.count(); + const approvals = state.admin.awaitingApproval.count(); return notifications + chats + reports + approvals; };