fix: notification badge (#2592)
Co-authored-by: Ayo <ramon.aycojr@gmail.com>
This commit is contained in:
parent
dcc1b74824
commit
1bbc2eca24
|
@ -10,8 +10,10 @@ export function useNotifications() {
|
||||||
async function clearNotifications() {
|
async function clearNotifications() {
|
||||||
if (!id || !notifications[id])
|
if (!id || !notifications[id])
|
||||||
return
|
return
|
||||||
|
|
||||||
const lastReadId = notifications[id]![1][0]
|
const lastReadId = notifications[id]![1][0]
|
||||||
notifications[id]![1] = []
|
notifications[id]![1] = []
|
||||||
|
|
||||||
if (lastReadId) {
|
if (lastReadId) {
|
||||||
await client.v1.markers.create({
|
await client.v1.markers.create({
|
||||||
notifications: { lastReadId },
|
notifications: { lastReadId },
|
||||||
|
@ -30,11 +32,11 @@ export function useNotifications() {
|
||||||
if (!isHydrated.value || !id || notifications[id] !== undefined || !currentUser.value?.token)
|
if (!isHydrated.value || !id || notifications[id] !== undefined || !currentUser.value?.token)
|
||||||
return
|
return
|
||||||
|
|
||||||
let resolveStream
|
let resolveStream: ((value: mastodon.streaming.Subscription | PromiseLike<mastodon.streaming.Subscription>) => void) | undefined
|
||||||
const streamPromise = new Promise<mastodon.streaming.Subscription>(resolve => resolveStream = resolve)
|
const streamPromise = new Promise<mastodon.streaming.Subscription>(resolve => resolveStream = resolve)
|
||||||
notifications[id] = [streamPromise, []]
|
notifications[id] = [streamPromise, []]
|
||||||
|
|
||||||
await until($$(streamingClient)).toBe(true)
|
await until($$(streamingClient)).toBeTruthy()
|
||||||
|
|
||||||
const stream = streamingClient!.user.subscribe()
|
const stream = streamingClient!.user.subscribe()
|
||||||
resolveStream!(stream)
|
resolveStream!(stream)
|
||||||
|
@ -43,6 +45,7 @@ export function useNotifications() {
|
||||||
|
|
||||||
const position = await client.v1.markers.fetch({ timeline: ['notifications'] })
|
const position = await client.v1.markers.fetch({ timeline: ['notifications'] })
|
||||||
const paginator = client.v1.notifications.list({ limit: 30 })
|
const paginator = client.v1.notifications.list({ limit: 30 })
|
||||||
|
|
||||||
do {
|
do {
|
||||||
const result = await paginator.next()
|
const result = await paginator.next()
|
||||||
if (!result.done && result.value.length) {
|
if (!result.done && result.value.length) {
|
||||||
|
|
Loading…
Reference in a new issue