feat: dashboard notifications list

This commit is contained in:
DIYgod
2022-10-31 01:11:18 +00:00
parent 47d489ea56
commit a3425eb9df
6 changed files with 212 additions and 2 deletions
+43
View File
@@ -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
})
}