From 6e001dbf1ce87f00f064a1a9f772c19185179f0e Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Wed, 27 Dec 2023 08:47:45 -0800 Subject: [PATCH] A couple notifications fixes (#2327) * Clear the app badge notif count on markallread * Fix like notifications on custom feeds --- src/state/queries/notifications/unread.tsx | 3 +++ src/state/queries/notifications/util.ts | 4 +++- src/view/com/notifications/FeedItem.tsx | 18 ++++++++++++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/state/queries/notifications/unread.tsx b/src/state/queries/notifications/unread.tsx index a189f20e42..abaabbf0e7 100644 --- a/src/state/queries/notifications/unread.tsx +++ b/src/state/queries/notifications/unread.tsx @@ -89,6 +89,9 @@ export function Provider({children}: React.PropsWithChildren<{}>) { // update & broadcast setNumUnread('') broadcast.postMessage({event: ''}) + if (isNative) { + Notifications.setBadgeCountAsync(0) + } }, async checkUnread({invalidate}: {invalidate?: boolean} = {}) { diff --git a/src/state/queries/notifications/util.ts b/src/state/queries/notifications/util.ts index 438879b7e8..411a0f791d 100644 --- a/src/state/queries/notifications/util.ts +++ b/src/state/queries/notifications/util.ts @@ -156,7 +156,7 @@ async function fetchSubjects( ): Promise> { const uris = new Set() for (const notif of groupedNotifs) { - if (notif.subjectUri) { + if (notif.subjectUri && !notif.subjectUri.includes('feed.generator')) { uris.add(notif.subjectUri) } } @@ -216,6 +216,8 @@ function getSubjectUri( ? notif.record.subject?.uri : undefined } + } else if (type === 'feedgen-like') { + return notif.reasonSubject } } diff --git a/src/view/com/notifications/FeedItem.tsx b/src/view/com/notifications/FeedItem.tsx index aaa2ea2c63..24b7e4fb6b 100644 --- a/src/view/com/notifications/FeedItem.tsx +++ b/src/view/com/notifications/FeedItem.tsx @@ -42,6 +42,7 @@ import {TimeElapsed} from '../util/TimeElapsed' import {isWeb} from 'platform/detection' import {Trans, msg} from '@lingui/macro' import {useLingui} from '@lingui/react' +import {FeedSourceCard} from '../feeds/FeedSourceCard' const MAX_AUTHORS = 5 @@ -112,7 +113,7 @@ let FeedItem = ({ ] }, [item, moderationOpts]) - if (item.subjectUri && !item.subject) { + if (item.subjectUri && !item.subject && item.type !== 'feedgen-like') { // don't render anything if the target post was deleted or unfindable return } @@ -166,7 +167,7 @@ let FeedItem = ({ iconStyle = [s.blue3 as FontAwesomeIconStyle] } else if (item.type === 'feedgen-like') { action = `liked your custom feed${ - item.subjectUri ? ` '${new AtUri(item.subjectUri).rkey}}'` : '' + item.subjectUri ? ` '${new AtUri(item.subjectUri).rkey}'` : '' }` icon = 'HeartIconSolid' iconStyle = [ @@ -256,6 +257,13 @@ let FeedItem = ({ {item.type === 'post-like' || item.type === 'repost' ? ( ) : null} + {item.type === 'feedgen-like' && item.subjectUri ? ( + + ) : null} ) @@ -496,6 +504,12 @@ const styles = StyleSheet.create({ marginLeft: 2, opacity: 0.8, }, + feedcard: { + borderWidth: 1, + borderRadius: 8, + paddingVertical: 12, + marginTop: 6, + }, addedContainer: { paddingTop: 4,