Remove all scenes-related items from notifications
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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}
|
||||
</View>
|
||||
<View style={styles.meta}>
|
||||
{item.isTrend && (
|
||||
<Text style={[styles.metaItem, pal.text]}>{action}</Text>
|
||||
)}
|
||||
<Link
|
||||
key={authors[0].href}
|
||||
style={styles.metaItem}
|
||||
@@ -193,25 +181,17 @@ export const FeedItem = observer(function FeedItem({
|
||||
</Text>
|
||||
</>
|
||||
) : undefined}
|
||||
{!item.isTrend && (
|
||||
<Text style={[styles.metaItem, pal.text]}>{action}</Text>
|
||||
)}
|
||||
<Text style={[styles.metaItem, pal.textLight]}>
|
||||
{ago(item.indexedAt)}
|
||||
</Text>
|
||||
</View>
|
||||
{item.isUpvote || item.isRepost || item.isTrend ? (
|
||||
{item.isUpvote || item.isRepost ? (
|
||||
<AdditionalPostText additionalPost={item.additionalPost} />
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
{item.isInvite && (
|
||||
<View style={styles.addedContainer}>
|
||||
<InviteAccepter item={item} />
|
||||
</View>
|
||||
)}
|
||||
</Link>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -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<string>('')
|
||||
const isMember =
|
||||
confirmationUri !== '' || store.me.memberships?.isMemberOf(item.author.did)
|
||||
const onPressAccept = async () => {
|
||||
store.shell.openModal(
|
||||
new ConfirmModal(
|
||||
'Join this scene?',
|
||||
() => (
|
||||
<View>
|
||||
<View style={styles.profileCardContainer}>
|
||||
<ProfileCard
|
||||
did={item.author.did}
|
||||
handle={item.author.handle}
|
||||
displayName={item.author.displayName}
|
||||
avatar={item.author.avatar}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
),
|
||||
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 (
|
||||
<View style={styles.container}>
|
||||
{!isMember ? (
|
||||
<TouchableOpacity onPress={onPressAccept}>
|
||||
<LinearGradient
|
||||
colors={[gradients.primary.start, gradients.primary.end]}
|
||||
start={{x: 0, y: 0}}
|
||||
end={{x: 1, y: 1}}
|
||||
style={[styles.btn]}>
|
||||
<Text style={[s.white, s.bold, s.f16]}>Accept Invite</Text>
|
||||
</LinearGradient>
|
||||
</TouchableOpacity>
|
||||
) : (
|
||||
<View style={styles.inviteAccepted}>
|
||||
<FontAwesomeIcon icon="check" size={14} style={s.mr5} />
|
||||
<Text style={[s.gray5, s.f15]}>Invite accepted</Text>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
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',
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user