forked from Mirrors/elk
fix: subscribe to proper user.notification stream (#2566)
This commit is contained in:
parent
b8e8693342
commit
7322711609
4 changed files with 2 additions and 6 deletions
|
@ -10,7 +10,6 @@ const {
|
||||||
stream,
|
stream,
|
||||||
keyProp = 'id',
|
keyProp = 'id',
|
||||||
virtualScroller = false,
|
virtualScroller = false,
|
||||||
eventType = 'update',
|
|
||||||
preprocess,
|
preprocess,
|
||||||
endMessage = true,
|
endMessage = true,
|
||||||
} = defineProps<{
|
} = defineProps<{
|
||||||
|
@ -18,7 +17,6 @@ const {
|
||||||
keyProp?: keyof T
|
keyProp?: keyof T
|
||||||
virtualScroller?: boolean
|
virtualScroller?: boolean
|
||||||
stream?: mastodon.streaming.Subscription
|
stream?: mastodon.streaming.Subscription
|
||||||
eventType?: 'notification' | 'update'
|
|
||||||
preprocess?: (items: (U | T)[]) => U[]
|
preprocess?: (items: (U | T)[]) => U[]
|
||||||
endMessage?: boolean | string
|
endMessage?: boolean | string
|
||||||
}>()
|
}>()
|
||||||
|
@ -46,7 +44,7 @@ defineSlots<{
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const nuxtApp = useNuxtApp()
|
const nuxtApp = useNuxtApp()
|
||||||
|
|
||||||
const { items, prevItems, update, state, endAnchor, error } = usePaginator(paginator, $$(stream), eventType, preprocess)
|
const { items, prevItems, update, state, endAnchor, error } = usePaginator(paginator, $$(stream), preprocess)
|
||||||
|
|
||||||
nuxtApp.hook('elk-logo:click', () => {
|
nuxtApp.hook('elk-logo:click', () => {
|
||||||
update()
|
update()
|
||||||
|
|
|
@ -172,7 +172,6 @@ const { formatNumber } = useHumanReadableNumber()
|
||||||
:preprocess="preprocess"
|
:preprocess="preprocess"
|
||||||
:stream="stream"
|
:stream="stream"
|
||||||
:virtualScroller="virtualScroller"
|
:virtualScroller="virtualScroller"
|
||||||
eventType="notification"
|
|
||||||
>
|
>
|
||||||
<template #updater="{ number, update }">
|
<template #updater="{ number, update }">
|
||||||
<button py-4 border="b base" flex="~ col" p-3 w-full text-primary font-bold @click="() => { update(); clearNotifications() }">
|
<button py-4 border="b base" flex="~ col" p-3 w-full text-primary font-bold @click="() => { update(); clearNotifications() }">
|
||||||
|
|
|
@ -9,7 +9,7 @@ const options = { limit: 30, types: filter ? [filter] : [] }
|
||||||
|
|
||||||
// Default limit is 20 notifications, and servers are normally caped to 30
|
// Default limit is 20 notifications, and servers are normally caped to 30
|
||||||
const paginator = useMastoClient().v1.notifications.list(options)
|
const paginator = useMastoClient().v1.notifications.list(options)
|
||||||
const stream = useStreaming(client => client.user.subscribe())
|
const stream = useStreaming(client => client.user.notification.subscribe())
|
||||||
|
|
||||||
const { clearNotifications } = useNotifications()
|
const { clearNotifications } = useNotifications()
|
||||||
onActivated(clearNotifications)
|
onActivated(clearNotifications)
|
||||||
|
|
|
@ -5,7 +5,6 @@ import type { PaginatorState } from '~/types'
|
||||||
export function usePaginator<T, P, U = T>(
|
export function usePaginator<T, P, U = T>(
|
||||||
_paginator: mastodon.Paginator<T[], P>,
|
_paginator: mastodon.Paginator<T[], P>,
|
||||||
stream: Ref<mastodon.streaming.Subscription | undefined>,
|
stream: Ref<mastodon.streaming.Subscription | undefined>,
|
||||||
eventType: 'notification' | 'update' = 'update',
|
|
||||||
preprocess: (items: (T | U)[]) => U[] = items => items as unknown as U[],
|
preprocess: (items: (T | U)[]) => U[] = items => items as unknown as U[],
|
||||||
buffer = 10,
|
buffer = 10,
|
||||||
) {
|
) {
|
||||||
|
|
Loading…
Reference in a new issue