Skip to content

Commit

Permalink
Use fastIsType
Browse files Browse the repository at this point in the history
  • Loading branch information
estrattonbailey committed Jan 6, 2025
1 parent 88dc3a0 commit 0b5c7a7
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/state/queries/notifications/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {QueryClient} from '@tanstack/react-query'
import chunk from 'lodash.chunk'

import {labelIsHideableOffense} from '#/lib/moderation'
import * as atp from '#/types/atproto'
import {precacheProfile} from '../profile'
import {FeedNotification, FeedPage, NotificationType} from './types'

Expand Down Expand Up @@ -255,14 +256,17 @@ function getSubjectUri(
return notif.uri
} else if (type === 'post-like' || type === 'repost') {
if (
AppBskyFeedRepost.isRecord(notif.record) ||
AppBskyFeedLike.isRecord(notif.record)
atp.fastIsType<AppBskyFeedRepost.Record>(
notif.record,
AppBskyFeedRepost.isRecord,
) ||
atp.fastIsType<AppBskyFeedLike.Record>(
notif.record,
AppBskyFeedLike.isRecord,
)
) {
const record = notif.record as
| AppBskyFeedRepost.Record
| AppBskyFeedLike.Record
return typeof record.subject?.uri === 'string'
? record.subject?.uri
return typeof notif.record.subject?.uri === 'string'
? notif.record.subject?.uri
: undefined
}
} else if (type === 'feedgen-like') {
Expand Down

0 comments on commit 0b5c7a7

Please sign in to comment.