lightened up notification utils by remove store stuff from it
This commit is contained in:
parent
ec05b20b06
commit
a31e6f660a
6 changed files with 13 additions and 14 deletions
|
|
@ -1,7 +1,6 @@
|
|||
import { readFile } from 'node:fs/promises'
|
||||
import { dirname, resolve } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import * as esbuild from 'esbuild'
|
||||
import { build } from 'vite'
|
||||
|
||||
import {
|
||||
|
|
@ -23,10 +22,6 @@ const getProdSwEnv = ({ assets }) =>
|
|||
|
||||
export const devSwPlugin = ({ swSrc, swDest, transformSW, alias }) => {
|
||||
const swFullSrc = resolve(projectRoot, swSrc)
|
||||
const esbuildAlias = {}
|
||||
Object.entries(alias).forEach(([source, dest]) => {
|
||||
esbuildAlias[source] = dest.startsWith('/') ? projectRoot + dest : dest
|
||||
})
|
||||
|
||||
return {
|
||||
name: 'dev-sw-plugin',
|
||||
|
|
@ -58,12 +53,11 @@ export const devSwPlugin = ({ swSrc, swDest, transformSW, alias }) => {
|
|||
*/
|
||||
async transform(code, id) {
|
||||
if (id === swFullSrc && transformSW) {
|
||||
const res = await esbuild.build({
|
||||
const res = await build({
|
||||
entryPoints: [swSrc],
|
||||
bundle: true,
|
||||
write: false,
|
||||
outfile: 'sw-pleroma.js',
|
||||
alias: esbuildAlias,
|
||||
plugins: [
|
||||
{
|
||||
name: 'vite-like-root-resolve',
|
||||
|
|
@ -140,7 +134,7 @@ export const buildSwPlugin = ({ swSrc, swDest }) => {
|
|||
formats: ['iife'],
|
||||
name: 'sw_pleroma',
|
||||
},
|
||||
emptyOutDir: false,
|
||||
emptyOutDir: true,
|
||||
rolldownOptions: {
|
||||
output: {
|
||||
entryFileNames: swDest,
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ const MobileNav = {
|
|||
countExtraNotifications(
|
||||
this.$store,
|
||||
useMergedConfigStore().mergedConfig,
|
||||
useAnnouncementsStore().unreadAnnouncementCount,
|
||||
)
|
||||
)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -115,6 +115,7 @@ const Notifications = {
|
|||
return countExtraNotifications(
|
||||
this.$store,
|
||||
useMergedConfigStore().mergedConfig,
|
||||
useAnnouncementsStore().unreadAnnouncementCount,
|
||||
)
|
||||
},
|
||||
unseenCountTitle() {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import {
|
|||
maybeShowNotification,
|
||||
} from '../services/notification_utils/notification_utils.js'
|
||||
|
||||
import { useI18nStore } from 'src/stores/i18n.js'
|
||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||
import { useReportsStore } from 'src/stores/reports.js'
|
||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||
|
|
@ -123,6 +124,7 @@ export const notifications = {
|
|||
useMergedConfigStore().mergedConfig.notificationVisibility,
|
||||
Object.values(useSyncConfigStore().prefsStorage.simple.muteFilters),
|
||||
notification,
|
||||
useI18nStore().i18n,
|
||||
)
|
||||
} else if (notification.seen) {
|
||||
state.idStore[notification.id].seen = true
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import { showDesktopNotification } from '../desktop_notification_utils/desktop_n
|
|||
import { muteFilterHits } from '../status_parser/status_parser.js'
|
||||
|
||||
import { useAnnouncementsStore } from 'src/stores/announcements.js'
|
||||
import { useI18nStore } from 'src/stores/i18n.js'
|
||||
|
||||
import FaviconService from 'src/services/favicon_service/favicon_service.js'
|
||||
|
||||
|
|
@ -76,6 +75,7 @@ export const maybeShowNotification = (
|
|||
notificationVisibility,
|
||||
muteFilters,
|
||||
notification,
|
||||
i18n,
|
||||
) => {
|
||||
const rootState = store.rootState || store.state
|
||||
|
||||
|
|
@ -89,7 +89,7 @@ export const maybeShowNotification = (
|
|||
|
||||
const notificationObject = prepareNotificationObject(
|
||||
notification,
|
||||
useI18nStore().i18n,
|
||||
i18n,
|
||||
)
|
||||
showDesktopNotification(rootState, notificationObject)
|
||||
}
|
||||
|
|
@ -193,7 +193,7 @@ export const prepareNotificationObject = (notification, i18n) => {
|
|||
return notifObj
|
||||
}
|
||||
|
||||
export const countExtraNotifications = (store, mergedConfig) => {
|
||||
export const countExtraNotifications = (store, mergedConfig, unreadAnnouncementCount) => {
|
||||
const rootGetters = store.rootGetters || store.getters
|
||||
|
||||
if (!mergedConfig.showExtraNotifications) {
|
||||
|
|
@ -205,7 +205,7 @@ export const countExtraNotifications = (store, mergedConfig) => {
|
|||
? rootGetters.unreadChatCount
|
||||
: 0,
|
||||
mergedConfig.showAnnouncementsInExtraNotifications
|
||||
? useAnnouncementsStore().unreadAnnouncementCount
|
||||
? unreadAnnouncementCount
|
||||
: 0,
|
||||
mergedConfig.showFollowRequestsInExtraNotifications
|
||||
? rootGetters.followRequestCount
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
/* eslint-env serviceworker */
|
||||
|
||||
import 'virtual:pleroma-fe/service_worker_env'
|
||||
|
||||
import { createI18n } from 'vue-i18n'
|
||||
|
||||
import { storage } from 'src/lib/storage.js'
|
||||
import { INSTANCE_DEFAULT_CONFIG } from 'src/modules/default_config_state.js'
|
||||
import { parseNotification } from 'src/services/entity_normalizer/entity_normalizer.service.js'
|
||||
import { prepareNotificationObject } from 'src/services/notification_utils/notification_utils.js'
|
||||
|
|
@ -33,7 +34,7 @@ function getWindowClients() {
|
|||
}
|
||||
|
||||
const setSettings = async () => {
|
||||
const piniaState = await storage.getItem('pinia-local-sync_config')
|
||||
const piniaState = {}
|
||||
const locale = piniaState.prefsStorage.simple.interfaceLanguage || 'en'
|
||||
i18n.locale = locale
|
||||
const notificationsNativeArray = Object.entries(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue