Remove all scenes-related items from notifications
This commit is contained in:
@@ -4,17 +4,15 @@ import {
|
|||||||
AppBskyActorRef as ActorRef,
|
AppBskyActorRef as ActorRef,
|
||||||
AppBskyFeedPost,
|
AppBskyFeedPost,
|
||||||
AppBskyFeedRepost,
|
AppBskyFeedRepost,
|
||||||
AppBskyFeedTrend,
|
|
||||||
AppBskyFeedVote,
|
AppBskyFeedVote,
|
||||||
AppBskyGraphAssertion,
|
AppBskyGraphAssertion,
|
||||||
AppBskyGraphFollow,
|
AppBskyGraphFollow,
|
||||||
APP_BSKY_GRAPH,
|
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
import {RootStoreModel} from './root-store'
|
import {RootStoreModel} from './root-store'
|
||||||
import {PostThreadViewModel} from './post-thread-view'
|
import {PostThreadViewModel} from './post-thread-view'
|
||||||
import {cleanError} from '../../lib/strings'
|
import {cleanError} from '../../lib/strings'
|
||||||
|
|
||||||
const UNGROUPABLE_REASONS = ['trend', 'assertion']
|
const UNGROUPABLE_REASONS = ['assertion']
|
||||||
const PAGE_SIZE = 30
|
const PAGE_SIZE = 30
|
||||||
const MS_60MIN = 1e3 * 60 * 60
|
const MS_60MIN = 1e3 * 60 * 60
|
||||||
|
|
||||||
@@ -27,7 +25,6 @@ export interface GroupedNotification extends ListNotifications.Notification {
|
|||||||
type SupportedRecord =
|
type SupportedRecord =
|
||||||
| AppBskyFeedPost.Record
|
| AppBskyFeedPost.Record
|
||||||
| AppBskyFeedRepost.Record
|
| AppBskyFeedRepost.Record
|
||||||
| AppBskyFeedTrend.Record
|
|
||||||
| AppBskyFeedVote.Record
|
| AppBskyFeedVote.Record
|
||||||
| AppBskyGraphAssertion.Record
|
| AppBskyGraphAssertion.Record
|
||||||
| AppBskyGraphFollow.Record
|
| AppBskyGraphFollow.Record
|
||||||
@@ -94,10 +91,6 @@ export class NotificationsViewItemModel {
|
|||||||
return this.reason === 'repost'
|
return this.reason === 'repost'
|
||||||
}
|
}
|
||||||
|
|
||||||
get isTrend() {
|
|
||||||
return this.reason === 'trend'
|
|
||||||
}
|
|
||||||
|
|
||||||
get isMention() {
|
get isMention() {
|
||||||
return this.reason === 'mention'
|
return this.reason === 'mention'
|
||||||
}
|
}
|
||||||
@@ -115,26 +108,12 @@ export class NotificationsViewItemModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get needsAdditionalData() {
|
get needsAdditionalData() {
|
||||||
if (
|
if (this.isUpvote || this.isRepost || this.isReply || this.isMention) {
|
||||||
this.isUpvote ||
|
|
||||||
this.isRepost ||
|
|
||||||
this.isTrend ||
|
|
||||||
this.isReply ||
|
|
||||||
this.isMention
|
|
||||||
) {
|
|
||||||
return !this.additionalPost
|
return !this.additionalPost
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
get isInvite() {
|
|
||||||
return (
|
|
||||||
this.isAssertion &&
|
|
||||||
AppBskyGraphAssertion.isRecord(this.record) &&
|
|
||||||
this.record.assertion === APP_BSKY_GRAPH.AssertMember
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
get subjectUri(): string {
|
get subjectUri(): string {
|
||||||
if (this.reasonSubject) {
|
if (this.reasonSubject) {
|
||||||
return this.reasonSubject
|
return this.reasonSubject
|
||||||
@@ -142,7 +121,6 @@ export class NotificationsViewItemModel {
|
|||||||
const record = this.record
|
const record = this.record
|
||||||
if (
|
if (
|
||||||
AppBskyFeedRepost.isRecord(record) ||
|
AppBskyFeedRepost.isRecord(record) ||
|
||||||
AppBskyFeedTrend.isRecord(record) ||
|
|
||||||
AppBskyFeedVote.isRecord(record)
|
AppBskyFeedVote.isRecord(record)
|
||||||
) {
|
) {
|
||||||
return record.subject.uri
|
return record.subject.uri
|
||||||
@@ -154,7 +132,6 @@ export class NotificationsViewItemModel {
|
|||||||
for (const ns of [
|
for (const ns of [
|
||||||
AppBskyFeedPost,
|
AppBskyFeedPost,
|
||||||
AppBskyFeedRepost,
|
AppBskyFeedRepost,
|
||||||
AppBskyFeedTrend,
|
|
||||||
AppBskyFeedVote,
|
AppBskyFeedVote,
|
||||||
AppBskyGraphAssertion,
|
AppBskyGraphAssertion,
|
||||||
AppBskyGraphFollow,
|
AppBskyGraphFollow,
|
||||||
@@ -185,7 +162,7 @@ export class NotificationsViewItemModel {
|
|||||||
let postUri
|
let postUri
|
||||||
if (this.isReply || this.isMention) {
|
if (this.isReply || this.isMention) {
|
||||||
postUri = this.uri
|
postUri = this.uri
|
||||||
} else if (this.isUpvote || this.isRepost || this.isTrend) {
|
} else if (this.isUpvote || this.isRepost) {
|
||||||
postUri = this.subjectUri
|
postUri = this.subjectUri
|
||||||
}
|
}
|
||||||
if (postUri) {
|
if (postUri) {
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import {UserAvatar} from '../util/UserAvatar'
|
|||||||
import {ErrorMessage} from '../util/error/ErrorMessage'
|
import {ErrorMessage} from '../util/error/ErrorMessage'
|
||||||
import {Post} from '../post/Post'
|
import {Post} from '../post/Post'
|
||||||
import {Link} from '../util/Link'
|
import {Link} from '../util/Link'
|
||||||
import {InviteAccepter} from './InviteAccepter'
|
|
||||||
import {usePalette} from '../../lib/hooks/usePalette'
|
import {usePalette} from '../../lib/hooks/usePalette'
|
||||||
|
|
||||||
const MAX_AUTHORS = 8
|
const MAX_AUTHORS = 8
|
||||||
@@ -26,7 +25,7 @@ export const FeedItem = observer(function FeedItem({
|
|||||||
}) {
|
}) {
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const itemHref = useMemo(() => {
|
const itemHref = useMemo(() => {
|
||||||
if (item.isUpvote || item.isRepost || item.isTrend) {
|
if (item.isUpvote || item.isRepost) {
|
||||||
const urip = new AtUri(item.subjectUri)
|
const urip = new AtUri(item.subjectUri)
|
||||||
return `/profile/${urip.host}/post/${urip.rkey}`
|
return `/profile/${urip.host}/post/${urip.rkey}`
|
||||||
} else if (item.isFollow || item.isAssertion) {
|
} else if (item.isFollow || item.isAssertion) {
|
||||||
@@ -82,10 +81,6 @@ export const FeedItem = observer(function FeedItem({
|
|||||||
action = 'reposted your post'
|
action = 'reposted your post'
|
||||||
icon = 'retweet'
|
icon = 'retweet'
|
||||||
iconStyle = [s.green3]
|
iconStyle = [s.green3]
|
||||||
} else if (item.isTrend) {
|
|
||||||
action = 'Your post is trending with'
|
|
||||||
icon = 'arrow-trend-up'
|
|
||||||
iconStyle = [s.red3]
|
|
||||||
} else if (item.isReply) {
|
} else if (item.isReply) {
|
||||||
action = 'replied to your post'
|
action = 'replied to your post'
|
||||||
icon = ['far', 'comment']
|
icon = ['far', 'comment']
|
||||||
@@ -93,10 +88,6 @@ export const FeedItem = observer(function FeedItem({
|
|||||||
action = 'followed you'
|
action = 'followed you'
|
||||||
icon = 'user-plus'
|
icon = 'user-plus'
|
||||||
iconStyle = [s.blue3]
|
iconStyle = [s.blue3]
|
||||||
} else if (item.isInvite) {
|
|
||||||
icon = 'users'
|
|
||||||
iconStyle = [s.blue3]
|
|
||||||
action = 'invited you to join their scene'
|
|
||||||
} else {
|
} else {
|
||||||
return <></>
|
return <></>
|
||||||
}
|
}
|
||||||
@@ -173,9 +164,6 @@ export const FeedItem = observer(function FeedItem({
|
|||||||
) : undefined}
|
) : undefined}
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.meta}>
|
<View style={styles.meta}>
|
||||||
{item.isTrend && (
|
|
||||||
<Text style={[styles.metaItem, pal.text]}>{action}</Text>
|
|
||||||
)}
|
|
||||||
<Link
|
<Link
|
||||||
key={authors[0].href}
|
key={authors[0].href}
|
||||||
style={styles.metaItem}
|
style={styles.metaItem}
|
||||||
@@ -193,25 +181,17 @@ export const FeedItem = observer(function FeedItem({
|
|||||||
</Text>
|
</Text>
|
||||||
</>
|
</>
|
||||||
) : undefined}
|
) : undefined}
|
||||||
{!item.isTrend && (
|
|
||||||
<Text style={[styles.metaItem, pal.text]}>{action}</Text>
|
|
||||||
)}
|
|
||||||
<Text style={[styles.metaItem, pal.textLight]}>
|
<Text style={[styles.metaItem, pal.textLight]}>
|
||||||
{ago(item.indexedAt)}
|
{ago(item.indexedAt)}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
{item.isUpvote || item.isRepost || item.isTrend ? (
|
{item.isUpvote || item.isRepost ? (
|
||||||
<AdditionalPostText additionalPost={item.additionalPost} />
|
<AdditionalPostText additionalPost={item.additionalPost} />
|
||||||
) : (
|
) : (
|
||||||
<></>
|
<></>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
{item.isInvite && (
|
|
||||||
<View style={styles.addedContainer}>
|
|
||||||
<InviteAccepter item={item} />
|
|
||||||
</View>
|
|
||||||
)}
|
|
||||||
</Link>
|
</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