Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A couple notifications fixes #2327

Merged
merged 2 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/state/queries/notifications/unread.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
// update & broadcast
setNumUnread('')
broadcast.postMessage({event: ''})
if (isNative) {
Notifications.setBadgeCountAsync(0)
}
},

async checkUnread({invalidate}: {invalidate?: boolean} = {}) {
Expand Down
4 changes: 3 additions & 1 deletion src/state/queries/notifications/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ async function fetchSubjects(
): Promise<Map<string, AppBskyFeedDefs.PostView>> {
const uris = new Set<string>()
for (const notif of groupedNotifs) {
if (notif.subjectUri) {
if (notif.subjectUri && !notif.subjectUri.includes('feed.generator')) {
uris.add(notif.subjectUri)
}
}
Expand Down Expand Up @@ -216,6 +216,8 @@ function getSubjectUri(
? notif.record.subject?.uri
: undefined
}
} else if (type === 'feedgen-like') {
return notif.reasonSubject
}
}

Expand Down
18 changes: 16 additions & 2 deletions src/view/com/notifications/FeedItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {TimeElapsed} from '../util/TimeElapsed'
import {isWeb} from 'platform/detection'
import {Trans, msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {FeedSourceCard} from '../feeds/FeedSourceCard'

const MAX_AUTHORS = 5

Expand Down Expand Up @@ -112,7 +113,7 @@ let FeedItem = ({
]
}, [item, moderationOpts])

if (item.subjectUri && !item.subject) {
if (item.subjectUri && !item.subject && item.type !== 'feedgen-like') {
// don't render anything if the target post was deleted or unfindable
return <View />
}
Expand Down Expand Up @@ -166,7 +167,7 @@ let FeedItem = ({
iconStyle = [s.blue3 as FontAwesomeIconStyle]
} else if (item.type === 'feedgen-like') {
action = `liked your custom feed${
item.subjectUri ? ` '${new AtUri(item.subjectUri).rkey}}'` : ''
item.subjectUri ? ` '${new AtUri(item.subjectUri).rkey}'` : ''
}`
icon = 'HeartIconSolid'
iconStyle = [
Expand Down Expand Up @@ -256,6 +257,13 @@ let FeedItem = ({
{item.type === 'post-like' || item.type === 'repost' ? (
<AdditionalPostText post={item.subject} />
) : null}
{item.type === 'feedgen-like' && item.subjectUri ? (
<FeedSourceCard
feedUri={item.subjectUri}
style={[pal.view, pal.border, styles.feedcard]}
showLikes
/>
) : null}
</View>
</Link>
)
Expand Down Expand Up @@ -496,6 +504,12 @@ const styles = StyleSheet.create({
marginLeft: 2,
opacity: 0.8,
},
feedcard: {
borderWidth: 1,
borderRadius: 8,
paddingVertical: 12,
marginTop: 6,
},

addedContainer: {
paddingTop: 4,
Expand Down