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