Skip to content

Commit

Permalink
fix: subscribe to proper user.notification stream (elk-zone#2566)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev authored Jan 21, 2024
1 parent b8e8693 commit 7322711
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 6 deletions.
4 changes: 1 addition & 3 deletions components/common/CommonPaginator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ const {
stream,
keyProp = 'id',
virtualScroller = false,
eventType = 'update',
preprocess,
endMessage = true,
} = defineProps<{
paginator: mastodon.Paginator<T[], O>
keyProp?: keyof T
virtualScroller?: boolean
stream?: mastodon.streaming.Subscription
eventType?: 'notification' | 'update'
preprocess?: (items: (U | T)[]) => U[]
endMessage?: boolean | string
}>()
Expand Down Expand Up @@ -46,7 +44,7 @@ defineSlots<{
const { t } = useI18n()
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', () => {
update()
Expand Down
1 change: 0 additions & 1 deletion components/notification/NotificationPaginator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ const { formatNumber } = useHumanReadableNumber()
:preprocess="preprocess"
:stream="stream"
:virtualScroller="virtualScroller"
eventType="notification"
>
<template #updater="{ number, update }">
<button py-4 border="b base" flex="~ col" p-3 w-full text-primary font-bold @click="() => { update(); clearNotifications() }">
Expand Down
2 changes: 1 addition & 1 deletion components/timeline/TimelineNotifications.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const options = { limit: 30, types: filter ? [filter] : [] }
// Default limit is 20 notifications, and servers are normally caped to 30
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()
onActivated(clearNotifications)
Expand Down
1 change: 0 additions & 1 deletion composables/paginator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type { PaginatorState } from '~/types'
export function usePaginator<T, P, U = T>(
_paginator: mastodon.Paginator<T[], P>,
stream: Ref<mastodon.streaming.Subscription | undefined>,
eventType: 'notification' | 'update' = 'update',
preprocess: (items: (T | U)[]) => U[] = items => items as unknown as U[],
buffer = 10,
) {
Expand Down

0 comments on commit 7322711

Please sign in to comment.