diff options
author | Hailey <me@haileyok.com> | 2024-07-31 11:16:14 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-31 11:16:14 -0700 |
commit | 70ffd387e3fc9c08076e9ff5f6df33fa86db8151 (patch) | |
tree | 25e5df64456cad6b88e27a6e08d8fcafc06e3deb | |
parent | 576cef88b550bacba26988a53c28fcc31bc9f8c5 (diff) | |
download | voidsky-70ffd387e3fc9c08076e9ff5f6df33fa86db8151.tar.zst |
Only show "followed you back" when appropriate (#4849)
* only show followed back when we should * try/catch * log * Update FeedItem.tsx * tweak
-rw-r--r-- | src/view/com/notifications/FeedItem.tsx | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/view/com/notifications/FeedItem.tsx b/src/view/com/notifications/FeedItem.tsx index 520a059ae..e4294eaa5 100644 --- a/src/view/com/notifications/FeedItem.tsx +++ b/src/view/com/notifications/FeedItem.tsx @@ -13,11 +13,13 @@ import { AppBskyEmbedRecordWithMedia, AppBskyFeedDefs, AppBskyFeedPost, + AppBskyGraphFollow, moderateProfile, ModerationDecision, ModerationOpts, } from '@atproto/api' import {AtUri} from '@atproto/api' +import {TID} from '@atproto/common-web' import {msg, plural, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {useNavigation} from '@react-navigation/native' @@ -184,10 +186,28 @@ let FeedItem = ({ action = _(msg`reposted your post`) icon = <RepostIcon size="xl" style={{color: t.palette.positive_600}} /> } else if (item.type === 'follow') { + let isFollowBack = false + if ( item.notification.author.viewer?.following && - gate('ungroup_follow_backs') + AppBskyGraphFollow.isRecord(item.notification.record) ) { + let followingTimestamp + try { + const rkey = new AtUri(item.notification.author.viewer.following).rkey + followingTimestamp = TID.fromStr(rkey).timestamp() + } catch (e) { + // For some reason the following URI was invalid. Default to it not being a follow back. + console.error('Invalid following URI') + } + if (followingTimestamp) { + const followedTimestamp = + new Date(item.notification.record.createdAt).getTime() * 1000 + isFollowBack = followedTimestamp > followingTimestamp + } + } + + if (isFollowBack && gate('ungroup_follow_backs')) { action = _(msg`followed you back`) } else { action = _(msg`followed you`) |