stacker.news/fragments/notifications.js
ekzyis 2597eb56f3
Item mention notifications (#1208)
* Parse internal refs to links

* Item mention notifications

* Also parse item mentions as URLs

* Fix subType determined by referrer item instead of referee item

* Ignore subType

Considering if the item that was referred to was a post or comment made the code more complex than initially necessary.

For example, notifications for /notifications are deduplicated based on item id and the same item could refer to posts and comments, so to include "one of your posts" or "one of your comments" in the title would require splitting notifications based on the type of referred item.

I didn't want to do this but also wanted to have consistent notification titles between push and /notifications, so I use "items" in both places now, even though I think using "items" isn't ideal from a user perspective. I think it might be confusing.

* Fix rootText

* Replace full links to #<id> syntax in push notifications

* Refactor mention code into separate functions
2024-06-03 12:12:42 -05:00

162 lines
3.0 KiB
JavaScript

import { gql } from '@apollo/client'
import { ITEM_FULL_FIELDS } from './items'
import { INVITE_FIELDS } from './invites'
import { SUB_FIELDS } from './subs'
export const HAS_NOTIFICATIONS = gql`{ hasNewNotes }`
export const NOTIFICATIONS = gql`
${ITEM_FULL_FIELDS}
${INVITE_FIELDS}
${SUB_FIELDS}
query Notifications($cursor: String, $inc: String) {
notifications(cursor: $cursor, inc: $inc) {
cursor
lastChecked
notifications {
__typename
... on Mention {
id
sortTime
mention
item {
...ItemFullFields
text
}
}
... on ItemMention {
id
sortTime
item {
...ItemFullFields
text
}
}
... on Votification {
id
sortTime
earnedSats
item {
...ItemFullFields
text
}
}
... on Revenue {
id
sortTime
earnedSats
subName
}
... on ForwardedVotification {
id
sortTime
earnedSats
item {
...ItemFullFields
text
}
}
... on Streak {
id
sortTime
days
}
... on Earn {
id
sortTime
minSortTime
earnedSats
sources {
posts
comments
tipPosts
tipComments
}
}
... on Referral {
id
sortTime
}
... on Reply {
id
sortTime
item {
...ItemFullFields
text
}
}
... on FollowActivity {
id
sortTime
item {
...ItemFullFields
text
}
}
... on TerritoryPost {
id
sortTime
item {
...ItemFullFields
text
}
}
... on TerritoryTransfer {
id
sortTime
sub {
...SubFields
}
}
... on Invitification {
id
sortTime
invite {
...InviteFields
}
}
... on JobChanged {
id
sortTime
item {
...ItemFields
}
}
... on SubStatus {
id
sortTime
sub {
...SubFields
}
}
... on InvoicePaid {
id
sortTime
earnedSats
invoice {
id
nostr
comment
lud18Data
}
}
... on WithdrawlPaid {
id
sortTime
earnedSats
withdrawl {
autoWithdraw
}
}
... on Reminder {
id
sortTime
item {
...ItemFullFields
}
}
}
}
} `