feat: dashboard notifications list
This commit is contained in:
@@ -6,6 +6,8 @@ import { toGateway } from "~/lib/ipfs-parser"
|
||||
import type Unidata from "unidata.js"
|
||||
import { createClient } from "@urql/core"
|
||||
import axios from "axios"
|
||||
import { indexer } from "~/queries/crossbell"
|
||||
import type { LinkEntity, NoteEntity } from "crossbell.js"
|
||||
|
||||
export const checkSubdomain = async ({
|
||||
subdomain,
|
||||
@@ -341,3 +343,44 @@ export async function unsubscribeFromSite(
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
export async function getNotifications(input: { siteCId: string }) {
|
||||
const [subscriptions, notes] = await Promise.all([
|
||||
indexer.getBacklinksOfCharacter(input.siteCId, {
|
||||
limit: 100,
|
||||
}),
|
||||
indexer.getNotes({
|
||||
toCharacterId: input.siteCId,
|
||||
limit: 100,
|
||||
includeCharacter: true,
|
||||
}),
|
||||
])
|
||||
|
||||
return [
|
||||
...(subscriptions.list.map(
|
||||
(
|
||||
item: LinkEntity & {
|
||||
type?: "backlinks"
|
||||
},
|
||||
) => {
|
||||
item.type = "backlinks"
|
||||
return item
|
||||
},
|
||||
) as any),
|
||||
]
|
||||
.concat(
|
||||
notes.list.map(
|
||||
(
|
||||
item: NoteEntity & {
|
||||
type?: "notes"
|
||||
},
|
||||
) => {
|
||||
item.type = "notes"
|
||||
return item
|
||||
},
|
||||
),
|
||||
)
|
||||
.sort((a, b) => {
|
||||
return b.createdAt > a.createdAt ? 1 : -1
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user