notification_utils.js

This commit is contained in:
Henry Jameson 2026-02-13 14:33:40 +02:00
commit 85976a61b8
2 changed files with 17 additions and 11 deletions

View file

@ -3,6 +3,7 @@ import { muteFilterHits } from '../status_parser/status_parser.js'
import { useAnnouncementsStore } from 'src/stores/announcements'
import { useI18nStore } from 'src/stores/i18n.js'
import { useSyncConfigStore } from 'src/stores/sync_config.js'
import FaviconService from 'src/services/favicon_service/favicon_service.js'
@ -19,8 +20,7 @@ export const notificationsFromStore = (store) => store.state.notifications.data
export const visibleTypes = (store) => {
// When called from within a module we need rootGetters to access wider scope
// however when called from a component (i.e. this.$store) we already have wider scope
const rootGetters = store.rootGetters || store.getters
const { notificationVisibility } = rootGetters.mergedConfig
const { notificationVisibility } = useSyncConfigStore().mergedConfig
return [
notificationVisibility.likes && 'like',

View file

@ -1,6 +1,21 @@
import { createTestingPinia } from '@pinia/testing'
import { useSyncConfigStore } from 'src/stores/sync_config.js'
import * as NotificationUtils from 'src/services/notification_utils/notification_utils.js'
describe('NotificationUtils', () => {
beforeEach(() => {
const store = useSyncConfigStore(createTestingPinia())
store.mergedConfig = {
notificationVisibility: {
likes: true,
repeats: true,
mentions: false,
},
}
})
describe('filteredNotificationsFromStore', () => {
it('should return sorted notifications with configured types', () => {
const store = {
@ -25,15 +40,6 @@ describe('NotificationUtils', () => {
],
},
},
getters: {
mergedConfig: {
notificationVisibility: {
likes: true,
repeats: true,
mentions: false,
},
},
},
}
const expected = [
{