fix: notifications in update timeline (#2740)

pull/2750/head
patak 2024-04-03 15:59:24 +02:00 zatwierdzone przez GitHub
rodzic d0b115751f
commit 59dda09cd4
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
3 zmienionych plików z 6 dodań i 2 usunięć

Wyświetl plik

@ -8,6 +8,7 @@ import type { UnwrapRef } from 'vue'
const { const {
paginator, paginator,
stream, stream,
eventType,
keyProp = 'id', keyProp = 'id',
virtualScroller = false, virtualScroller = false,
preprocess, preprocess,
@ -17,6 +18,7 @@ const {
keyProp?: keyof T keyProp?: keyof T
virtualScroller?: boolean virtualScroller?: boolean
stream?: mastodon.streaming.Subscription stream?: mastodon.streaming.Subscription
eventType?: 'update' | 'notification'
preprocess?: (items: (U | T)[]) => U[] preprocess?: (items: (U | T)[]) => U[]
endMessage?: boolean | string endMessage?: boolean | string
}>() }>()
@ -44,7 +46,7 @@ defineSlots<{
const { t } = useI18n() const { t } = useI18n()
const nuxtApp = useNuxtApp() const nuxtApp = useNuxtApp()
const { items, prevItems, update, state, endAnchor, error } = usePaginator(paginator, toRef(() => stream), preprocess) const { items, prevItems, update, state, endAnchor, error } = usePaginator(paginator, toRef(() => stream), eventType, preprocess)
nuxtApp.hook('elk-logo:click', () => { nuxtApp.hook('elk-logo:click', () => {
update() update()

Wyświetl plik

@ -171,6 +171,7 @@ const { formatNumber } = useHumanReadableNumber()
:paginator="paginator" :paginator="paginator"
:preprocess="preprocess" :preprocess="preprocess"
:stream="stream" :stream="stream"
eventType="notification"
:virtualScroller="virtualScroller" :virtualScroller="virtualScroller"
> >
<template #updater="{ number, update }"> <template #updater="{ number, update }">

Wyświetl plik

@ -5,6 +5,7 @@ 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: 'update' | 'notification' = '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,
) { ) {
@ -34,7 +35,7 @@ export function usePaginator<T, P, U = T>(
return return
for await (const entry of stream) { for await (const entry of stream) {
if (entry.event === 'update' || entry.event === 'notification') { if (entry.event === eventType) {
const status = entry.payload const status = entry.payload
if ('uri' in status) if ('uri' in status)