From beb74aee37be7d73881d92b294b9c0857c0bf95b Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Mon, 16 Jan 2023 14:03:48 -0600 Subject: [PATCH] Remove all scenes-related items from notifications --- src/state/models/notifications-view.ts | 29 +----- src/view/com/notifications/FeedItem.tsx | 24 +---- src/view/com/notifications/InviteAccepter.tsx | 95 ------------------- 3 files changed, 5 insertions(+), 143 deletions(-) delete mode 100644 src/view/com/notifications/InviteAccepter.tsx diff --git a/src/state/models/notifications-view.ts b/src/state/models/notifications-view.ts index c169a995c0..c4d2b2dfa5 100644 --- a/src/state/models/notifications-view.ts +++ b/src/state/models/notifications-view.ts @@ -4,17 +4,15 @@ import { AppBskyActorRef as ActorRef, AppBskyFeedPost, AppBskyFeedRepost, - AppBskyFeedTrend, AppBskyFeedVote, AppBskyGraphAssertion, AppBskyGraphFollow, - APP_BSKY_GRAPH, } from '@atproto/api' import {RootStoreModel} from './root-store' import {PostThreadViewModel} from './post-thread-view' import {cleanError} from '../../lib/strings' -const UNGROUPABLE_REASONS = ['trend', 'assertion'] +const UNGROUPABLE_REASONS = ['assertion'] const PAGE_SIZE = 30 const MS_60MIN = 1e3 * 60 * 60 @@ -27,7 +25,6 @@ export interface GroupedNotification extends ListNotifications.Notification { type SupportedRecord = | AppBskyFeedPost.Record | AppBskyFeedRepost.Record - | AppBskyFeedTrend.Record | AppBskyFeedVote.Record | AppBskyGraphAssertion.Record | AppBskyGraphFollow.Record @@ -94,10 +91,6 @@ export class NotificationsViewItemModel { return this.reason === 'repost' } - get isTrend() { - return this.reason === 'trend' - } - get isMention() { return this.reason === 'mention' } @@ -115,26 +108,12 @@ export class NotificationsViewItemModel { } get needsAdditionalData() { - if ( - this.isUpvote || - this.isRepost || - this.isTrend || - this.isReply || - this.isMention - ) { + if (this.isUpvote || this.isRepost || this.isReply || this.isMention) { return !this.additionalPost } return false } - get isInvite() { - return ( - this.isAssertion && - AppBskyGraphAssertion.isRecord(this.record) && - this.record.assertion === APP_BSKY_GRAPH.AssertMember - ) - } - get subjectUri(): string { if (this.reasonSubject) { return this.reasonSubject @@ -142,7 +121,6 @@ export class NotificationsViewItemModel { const record = this.record if ( AppBskyFeedRepost.isRecord(record) || - AppBskyFeedTrend.isRecord(record) || AppBskyFeedVote.isRecord(record) ) { return record.subject.uri @@ -154,7 +132,6 @@ export class NotificationsViewItemModel { for (const ns of [ AppBskyFeedPost, AppBskyFeedRepost, - AppBskyFeedTrend, AppBskyFeedVote, AppBskyGraphAssertion, AppBskyGraphFollow, @@ -185,7 +162,7 @@ export class NotificationsViewItemModel { let postUri if (this.isReply || this.isMention) { postUri = this.uri - } else if (this.isUpvote || this.isRepost || this.isTrend) { + } else if (this.isUpvote || this.isRepost) { postUri = this.subjectUri } if (postUri) { diff --git a/src/view/com/notifications/FeedItem.tsx b/src/view/com/notifications/FeedItem.tsx index c578b71207..739487859f 100644 --- a/src/view/com/notifications/FeedItem.tsx +++ b/src/view/com/notifications/FeedItem.tsx @@ -14,7 +14,6 @@ import {UserAvatar} from '../util/UserAvatar' import {ErrorMessage} from '../util/error/ErrorMessage' import {Post} from '../post/Post' import {Link} from '../util/Link' -import {InviteAccepter} from './InviteAccepter' import {usePalette} from '../../lib/hooks/usePalette' const MAX_AUTHORS = 8 @@ -26,7 +25,7 @@ export const FeedItem = observer(function FeedItem({ }) { const pal = usePalette('default') const itemHref = useMemo(() => { - if (item.isUpvote || item.isRepost || item.isTrend) { + if (item.isUpvote || item.isRepost) { const urip = new AtUri(item.subjectUri) return `/profile/${urip.host}/post/${urip.rkey}` } else if (item.isFollow || item.isAssertion) { @@ -82,10 +81,6 @@ export const FeedItem = observer(function FeedItem({ action = 'reposted your post' icon = 'retweet' iconStyle = [s.green3] - } else if (item.isTrend) { - action = 'Your post is trending with' - icon = 'arrow-trend-up' - iconStyle = [s.red3] } else if (item.isReply) { action = 'replied to your post' icon = ['far', 'comment'] @@ -93,10 +88,6 @@ export const FeedItem = observer(function FeedItem({ action = 'followed you' icon = 'user-plus' iconStyle = [s.blue3] - } else if (item.isInvite) { - icon = 'users' - iconStyle = [s.blue3] - action = 'invited you to join their scene' } else { return <> } @@ -173,9 +164,6 @@ export const FeedItem = observer(function FeedItem({ ) : undefined} - {item.isTrend && ( - {action} - )} ) : undefined} - {!item.isTrend && ( - {action} - )} {ago(item.indexedAt)} - {item.isUpvote || item.isRepost || item.isTrend ? ( + {item.isUpvote || item.isRepost ? ( ) : ( <> )} - {item.isInvite && ( - - - - )} ) }) diff --git a/src/view/com/notifications/InviteAccepter.tsx b/src/view/com/notifications/InviteAccepter.tsx deleted file mode 100644 index eefe7a273f..0000000000 --- a/src/view/com/notifications/InviteAccepter.tsx +++ /dev/null @@ -1,95 +0,0 @@ -import React, {useState} from 'react' -import {StyleSheet, TouchableOpacity, View} from 'react-native' -import LinearGradient from 'react-native-linear-gradient' -import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' -import * as apilib from '../../../state/lib/api' -import {NotificationsViewItemModel} from '../../../state/models/notifications-view' -import {ConfirmModal} from '../../../state/models/shell-ui' -import {useStores} from '../../../state' -import {ProfileCard} from '../profile/ProfileCard' -import * as Toast from '../util/Toast' -import {Text} from '../util/text/Text' -import {s, colors, gradients} from '../../lib/styles' - -export function InviteAccepter({item}: {item: NotificationsViewItemModel}) { - const store = useStores() - const [confirmationUri, setConfirmationUri] = useState('') - const isMember = - confirmationUri !== '' || store.me.memberships?.isMemberOf(item.author.did) - const onPressAccept = async () => { - store.shell.openModal( - new ConfirmModal( - 'Join this scene?', - () => ( - - - - - - ), - onPressConfirmAccept, - ), - ) - } - const onPressConfirmAccept = async () => { - const uri = await apilib.acceptSceneInvite(store, { - originator: { - did: item.author.did, - declarationCid: item.author.declaration.cid, - }, - assertion: { - uri: item.uri, - cid: item.cid, - }, - }) - store.me.refreshMemberships() - Toast.show('Invite accepted') - setConfirmationUri(uri) - } - return ( - - {!isMember ? ( - - - Accept Invite - - - ) : ( - - - Invite accepted - - )} - - ) -} - -const styles = StyleSheet.create({ - container: { - flexDirection: 'row', - }, - btn: { - borderRadius: 32, - paddingHorizontal: 18, - paddingVertical: 8, - backgroundColor: colors.gray1, - }, - profileCardContainer: { - borderWidth: 1, - borderColor: colors.gray3, - borderRadius: 6, - }, - inviteAccepted: { - flexDirection: 'row', - alignItems: 'center', - }, -})