Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: notifications in update timeline #2740

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion components/common/CommonPaginator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { UnwrapRef } from 'vue'
const {
paginator,
stream,
eventType,
keyProp = 'id',
virtualScroller = false,
preprocess,
Expand All @@ -17,6 +18,7 @@ const {
keyProp?: keyof T
virtualScroller?: boolean
stream?: mastodon.streaming.Subscription
eventType?: 'update' | 'notification'
preprocess?: (items: (U | T)[]) => U[]
endMessage?: boolean | string
}>()
Expand Down Expand Up @@ -44,7 +46,7 @@ defineSlots<{
const { t } = useI18n()
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', () => {
update()
Expand Down
1 change: 1 addition & 0 deletions components/notification/NotificationPaginator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ const { formatNumber } = useHumanReadableNumber()
:paginator="paginator"
:preprocess="preprocess"
:stream="stream"
eventType="notification"
:virtualScroller="virtualScroller"
>
<template #updater="{ number, update }">
Expand Down
3 changes: 2 additions & 1 deletion composables/paginator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { PaginatorState } from '~/types'
export function usePaginator<T, P, U = T>(
_paginator: mastodon.Paginator<T[], P>,
stream: Ref<mastodon.streaming.Subscription | undefined>,
eventType: 'update' | 'notification' = 'update',
preprocess: (items: (T | U)[]) => U[] = items => items as unknown as U[],
buffer = 10,
) {
Expand Down Expand Up @@ -34,7 +35,7 @@ export function usePaginator<T, P, U = T>(
return

for await (const entry of stream) {
if (entry.event === 'update' || entry.event === 'notification') {
if (entry.event === eventType) {
const status = entry.payload

if ('uri' in status)
Expand Down
Loading