Bluesky app fork with some witchin' additions 💫

Only show "followed you back" when appropriate (#4849)

* only show followed back when we should

* try/catch

* log

* Update FeedItem.tsx

* tweak

authored by hailey.at and committed by

GitHub 70ffd387 576cef88

+21 -1
+21 -1
src/view/com/notifications/FeedItem.tsx
··· 13 13 AppBskyEmbedRecordWithMedia, 14 14 AppBskyFeedDefs, 15 15 AppBskyFeedPost, 16 + AppBskyGraphFollow, 16 17 moderateProfile, 17 18 ModerationDecision, 18 19 ModerationOpts, 19 20 } from '@atproto/api' 20 21 import {AtUri} from '@atproto/api' 22 + import {TID} from '@atproto/common-web' 21 23 import {msg, plural, Trans} from '@lingui/macro' 22 24 import {useLingui} from '@lingui/react' 23 25 import {useNavigation} from '@react-navigation/native' ··· 184 186 action = _(msg`reposted your post`) 185 187 icon = <RepostIcon size="xl" style={{color: t.palette.positive_600}} /> 186 188 } else if (item.type === 'follow') { 189 + let isFollowBack = false 190 + 187 191 if ( 188 192 item.notification.author.viewer?.following && 189 - gate('ungroup_follow_backs') 193 + AppBskyGraphFollow.isRecord(item.notification.record) 190 194 ) { 195 + let followingTimestamp 196 + try { 197 + const rkey = new AtUri(item.notification.author.viewer.following).rkey 198 + followingTimestamp = TID.fromStr(rkey).timestamp() 199 + } catch (e) { 200 + // For some reason the following URI was invalid. Default to it not being a follow back. 201 + console.error('Invalid following URI') 202 + } 203 + if (followingTimestamp) { 204 + const followedTimestamp = 205 + new Date(item.notification.record.createdAt).getTime() * 1000 206 + isFollowBack = followedTimestamp > followingTimestamp 207 + } 208 + } 209 + 210 + if (isFollowBack && gate('ungroup_follow_backs')) { 191 211 action = _(msg`followed you back`) 192 212 } else { 193 213 action = _(msg`followed you`)