From e3ee3eaccae6a9ece674d7d76db8e67da499d6c3 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Sun, 19 Nov 2023 15:24:34 +0200 Subject: added some settings for notifications --- src/i18n/en.json | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/i18n') diff --git a/src/i18n/en.json b/src/i18n/en.json index 034022cb..b31793cb 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -688,6 +688,11 @@ "greentext": "Meme arrows", "show_yous": "Show (You)s", "notifications": "Notifications", + "notification_setting_annoyance": "Annoyance", + "notification_setting_drawer_marks_as_seen": "Closing drawer (mobile) marks all notifications as read", + "notification_setting_ignore_inactionable_seen": "Ignore read state of inactionable notifications (likes, repeats etc)", + "notification_setting_ignore_inactionable_seen_tip": "This will not actually mark those notifications as read, and you'll still get desktop notifications about them if you chose so", + "notification_setting_unseen_at_top": "Show unread notifications above others", "notification_setting_filters": "Filters", "notification_setting_block_from_strangers": "Block notifications from users who you do not follow", "notification_setting_privacy": "Privacy", -- cgit v1.2.3-70-g09d2 From fd3ad106bed2a5f790556bae200de5c352c5c0ea Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Sun, 19 Nov 2023 16:12:43 +0200 Subject: rearrange notification visibility page a bit. --- src/components/settings_modal/settings_modal.scss | 12 ++ .../settings_modal/tabs/notifications_tab.js | 4 + .../settings_modal/tabs/notifications_tab.vue | 133 +++++++++++++++++---- src/i18n/en.json | 3 + src/modules/config.js | 13 +- 5 files changed, 139 insertions(+), 26 deletions(-) (limited to 'src/i18n') diff --git a/src/components/settings_modal/settings_modal.scss b/src/components/settings_modal/settings_modal.scss index 49ef83e0..6bc9459b 100644 --- a/src/components/settings_modal/settings_modal.scss +++ b/src/components/settings_modal/settings_modal.scss @@ -3,6 +3,10 @@ .settings-modal { overflow: hidden; + h4 { + margin-bottom: 0.5em; + } + .setting-list, .option-list { list-style-type: none; @@ -15,6 +19,14 @@ .suboptions { margin-top: 0.3em; } + + &.two-column { + column-count: 2; + + > li { + break-inside: avoid; + } + } } .setting-description { diff --git a/src/components/settings_modal/tabs/notifications_tab.js b/src/components/settings_modal/tabs/notifications_tab.js index 3c6ab87f..c53b5889 100644 --- a/src/components/settings_modal/tabs/notifications_tab.js +++ b/src/components/settings_modal/tabs/notifications_tab.js @@ -16,6 +16,10 @@ const NotificationsTab = { user () { return this.$store.state.users.currentUser }, + canReceiveReports () { + if (!this.user) { return false } + return this.user.privileges.includes('reports_manage_reports') + }, ...SharedComputedObject() }, methods: { diff --git a/src/components/settings_modal/tabs/notifications_tab.vue b/src/components/settings_modal/tabs/notifications_tab.vue index fcee85a0..00d0f921 100644 --- a/src/components/settings_modal/tabs/notifications_tab.vue +++ b/src/components/settings_modal/tabs/notifications_tab.vue @@ -34,43 +34,128 @@ {{ $t('settings.notification_setting_block_from_strangers') }} -
  • - {{ $t('settings.notification_visibility') }} -
      +
    • +

      {{ $t('settings.notification_visibility') }}

      +
      • - - {{ $t('settings.notification_visibility_likes') }} - +

        {{ $t('settings.notification_visibility_mentions') }}

        +
          +
        • + + {{ $t('settings.notification_visibility_in_column') }} + +
        • +
        • + + {{ $t('settings.notification_visibility_native_notifications') }} + +
        • +
      • - - {{ $t('settings.notification_visibility_repeats') }} - +

        {{ $t('settings.notification_visibility_likes') }}

        +
          +
        • + + {{ $t('settings.notification_visibility_in_column') }} + +
        • +
        • + + {{ $t('settings.notification_visibility_native_notifications') }} + +
        • +
      • - - {{ $t('settings.notification_visibility_follows') }} - +

        {{ $t('settings.notification_visibility_repeats') }}

        +
          +
        • + + {{ $t('settings.notification_visibility_in_column') }} + +
        • +
        • + + {{ $t('settings.notification_visibility_native_notifications') }} + +
        • +
      • - - {{ $t('settings.notification_visibility_mentions') }} - +

        {{ $t('settings.notification_visibility_emoji_reactions') }}

        +
          +
        • + + {{ $t('settings.notification_visibility_in_column') }} + +
        • +
        • + + {{ $t('settings.notification_visibility_native_notifications') }} + +
        • +
      • - - {{ $t('settings.notification_visibility_moves') }} - +

        {{ $t('settings.notification_visibility_follows') }}

        +
          +
        • + + {{ $t('settings.notification_visibility_in_column') }} + +
        • +
        • + + {{ $t('settings.notification_visibility_native_notifications') }} + +
        • +
      • - - {{ $t('settings.notification_visibility_emoji_reactions') }} - +

        {{ $t('settings.notification_visibility_moves') }}

        +
          +
        • + + {{ $t('settings.notification_visibility_in_column') }} + +
        • +
        • + + {{ $t('settings.notification_visibility_native_notifications') }} + +
        • +
      • - - {{ $t('settings.notification_visibility_polls') }} - +

        {{ $t('settings.notification_visibility_polls') }}

        +
          +
        • + + {{ $t('settings.notification_visibility_in_column') }} + +
        • +
        • + + {{ $t('settings.notification_visibility_native_notifications') }} + +
        • +
        +
      • +
      • +

        {{ $t('settings.notification_visibility_reports') }}

        +
          +
        • + + {{ $t('settings.notification_visibility_in_column') }} + +
        • +
        • + + {{ $t('settings.notification_visibility_native_notifications') }} + +
        • +
    • diff --git a/src/i18n/en.json b/src/i18n/en.json index b31793cb..658e3b8e 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -561,10 +561,13 @@ "posts": "Posts", "user_profiles": "User Profiles", "notification_visibility": "Types of notifications to show", + "notification_visibility_in_column": "Show in notifications column/drawer", + "notification_visibility_native_notifications": "Show a native notification", "notification_visibility_follows": "Follows", "notification_visibility_likes": "Favorites", "notification_visibility_mentions": "Mentions", "notification_visibility_repeats": "Repeats", + "notification_visibility_reports": "Reports", "notification_visibility_moves": "User Migrates", "notification_visibility_emoji_reactions": "Reactions", "notification_visibility_polls": "Ends of polls you voted in", diff --git a/src/modules/config.js b/src/modules/config.js index a3f7bcaf..db1d564e 100644 --- a/src/modules/config.js +++ b/src/modules/config.js @@ -66,8 +66,17 @@ export const defaultState = { chatMention: true, polls: true }, - notificationSettings: { - nativeNotifications: ['follows', 'mentions', 'followRequest', 'reports', 'chatMention', 'polls'] + notificationNative: { + follows: true, + mentions: true, + likes: false, + repeats: false, + moves: false, + emojiReactions: false, + followRequest: true, + reports: true, + chatMention: true, + polls: true }, webPushNotifications: false, muteWords: [], -- cgit v1.2.3-70-g09d2 From 072a06fc89844a5ed2f557634b7e04c1ef63041d Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Sun, 19 Nov 2023 16:40:30 +0200 Subject: reports visibility setting + actual filtering for desktop notifs --- .../settings_modal/tabs/notifications_tab.vue | 15 +++++++ src/i18n/en.json | 1 + .../notification_utils/notification_utils.js | 1 + src/sw.js | 51 ++++++++++++++++++---- 4 files changed, 59 insertions(+), 9 deletions(-) (limited to 'src/i18n') diff --git a/src/components/settings_modal/tabs/notifications_tab.vue b/src/components/settings_modal/tabs/notifications_tab.vue index ffaa5723..a6f0cba2 100644 --- a/src/components/settings_modal/tabs/notifications_tab.vue +++ b/src/components/settings_modal/tabs/notifications_tab.vue @@ -114,6 +114,21 @@
  • +
  • +

    {{ $t('settings.notification_visibility_follow_requests') }}

    +
      +
    • + + {{ $t('settings.notification_visibility_in_column') }} + +
    • +
    • + + {{ $t('settings.notification_visibility_native_notifications') }} + +
    • +
    +
  • {{ $t('settings.notification_visibility_moves') }}

      diff --git a/src/i18n/en.json b/src/i18n/en.json index 658e3b8e..40da7155 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -564,6 +564,7 @@ "notification_visibility_in_column": "Show in notifications column/drawer", "notification_visibility_native_notifications": "Show a native notification", "notification_visibility_follows": "Follows", + "notification_visibility_follow_requests": "Follow requests", "notification_visibility_likes": "Favorites", "notification_visibility_mentions": "Mentions", "notification_visibility_repeats": "Repeats", diff --git a/src/services/notification_utils/notification_utils.js b/src/services/notification_utils/notification_utils.js index 342fe6ef..cc7e6817 100644 --- a/src/services/notification_utils/notification_utils.js +++ b/src/services/notification_utils/notification_utils.js @@ -91,6 +91,7 @@ export const prepareNotificationObject = (notification, i18n) => { const notifObj = { tag: notification.id, + type: notification.type, badge: cachedBadgeUrl } const status = notification.status diff --git a/src/sw.js b/src/sw.js index f5fccc6a..469291b9 100644 --- a/src/sw.js +++ b/src/sw.js @@ -15,7 +15,8 @@ const i18n = createI18n({ const state = { lastFocused: null, - notificationIds: new Set() + notificationIds: new Set(), + allowedNotificationTypes: null } function getWindowClients () { @@ -23,15 +24,43 @@ function getWindowClients () { .then((clientList) => clientList.filter(({ type }) => type === 'window')) } -const setLocale = async () => { - const state = await localForage.getItem('vuex-lz') - const locale = state.config.interfaceLanguage || 'en' +const setSettings = async () => { + const vuexState = await localForage.getItem('vuex-lz') + const locale = vuexState.config.interfaceLanguage || 'en' i18n.locale = locale + const notificationsNativeArray = Object.entries(vuexState.config.notificationNative) + + state.allowedNotificationTypes = new Set( + notificationsNativeArray + .filter(([k, v]) => v) + .map(([k]) => { + switch (k) { + case 'mentions': + return 'mention' + case 'likes': + return 'like' + case 'repeats': + return 'repeat' + case 'emojiReactions': + return 'pleroma:emoji_reaction' + case 'reports': + return 'pleroma:report' + case 'followRequest': + return 'follow_request' + case 'follows': + return 'follow' + case 'polls': + return 'poll' + default: + return k + } + }) + ) } const showPushNotification = async (event) => { const activeClients = await getWindowClients() - await setLocale() + await setSettings() // Only show push notifications if all tabs/windows are closed if (activeClients.length === 0) { const data = event.data.json() @@ -43,27 +72,31 @@ const showPushNotification = async (event) => { const res = prepareNotificationObject(parsedNotification, i18n) - self.registration.showNotification(res.title, res) + if (state.allowedNotificationTypes.has(parsedNotification.type)) { + self.registration.showNotification(res.title, res) + } } } self.addEventListener('push', async (event) => { - console.log(event) if (event.data) { event.waitUntil(showPushNotification(event)) } }) self.addEventListener('message', async (event) => { + await setSettings() const { type, content } = event.data if (type === 'desktopNotification') { const { title, ...rest } = content - const { tag } = rest + const { tag, type } = rest if (state.notificationIds.has(tag)) return state.notificationIds.add(tag) setTimeout(() => state.notificationIds.delete(tag), 10000) - self.registration.showNotification(title, rest) + if (state.allowedNotificationTypes.has(type)) { + self.registration.showNotification(title, rest) + } } if (type === 'desktopNotificationClose') { -- cgit v1.2.3-70-g09d2 From 4e8bb80dbd0ff5993f5613c6cbdfe757af0d0807 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Wed, 13 Dec 2023 20:37:40 +0200 Subject: fix incorrect title + add counter --- src/components/mobile_nav/mobile_nav.js | 6 ++++++ src/components/mobile_nav/mobile_nav.vue | 10 ++++++++-- src/i18n/en.json | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) (limited to 'src/i18n') diff --git a/src/components/mobile_nav/mobile_nav.js b/src/components/mobile_nav/mobile_nav.js index 0cd67990..ec9aeed0 100644 --- a/src/components/mobile_nav/mobile_nav.js +++ b/src/components/mobile_nav/mobile_nav.js @@ -57,6 +57,12 @@ const MobileNav = { unseenNotificationsCount () { return this.unseenNotifications.length + countExtraNotifications(this.$store) }, + unseenCount () { + return this.unseenNotifications.length + }, + unseenCountBadgeText () { + return `${this.unseenCount ? this.unseenCount : ''}${this.extraNotificationsCount ? '*' : ''}` + }, hideSitename () { return this.$store.state.instance.hideSitename }, sitename () { return this.$store.state.instance.name }, isChat () { diff --git a/src/components/mobile_nav/mobile_nav.vue b/src/components/mobile_nav/mobile_nav.vue index ecd8290a..f20a509d 100644 --- a/src/components/mobile_nav/mobile_nav.vue +++ b/src/components/mobile_nav/mobile_nav.vue @@ -50,7 +50,13 @@ @touchmove.stop="notificationsTouchMove" >
      - {{ $t('notifications.notifications') }} + + {{ $t('notifications.notifications') }} + {{ unseenCountBadgeText }} +
    • - + {{ $t('settings.notification_setting_unseen_at_top') }}
    • @@ -38,6 +38,7 @@
    • {{ $t('settings.notification_visibility') }}

      +

      {{ $t('settings.notification_setting_filters_chrome_push') }}

      • {{ $t('settings.notification_visibility_mentions') }}

        @@ -233,6 +234,21 @@ > {{ $t('settings.enable_web_push_notifications') }} +
          +
        • + + {{ $t('settings.enable_web_push_always_show') }} + +
          + + {{ $t('settings.enable_web_push_always_show_tip') }} + +
          +
        • +
      • { const locale = vuexState.config.interfaceLanguage || 'en' i18n.locale = locale const notificationsNativeArray = Object.entries(vuexState.config.notificationNative) + state.webPushAlwaysShowNotifications = vuexState.config.webPushAlwaysShowNotifications state.allowedNotificationTypes = new Set( notificationsNativeArray @@ -62,7 +63,7 @@ const showPushNotification = async (event) => { const activeClients = await getWindowClients() await setSettings() // Only show push notifications if all tabs/windows are closed - if (activeClients.length === 0) { + if (state.webPushAlwaysShowNotifications || activeClients.length === 0) { const data = event.data.json() const url = `${self.registration.scope}api/v1/notifications/${data.notification_id}` @@ -72,7 +73,7 @@ const showPushNotification = async (event) => { const res = prepareNotificationObject(parsedNotification, i18n) - if (state.allowedNotificationTypes.has(parsedNotification.type)) { + if (state.webPushAlwaysShowNotifications || state.allowedNotificationTypes.has(parsedNotification.type)) { return self.registration.showNotification(res.title, res) } } -- cgit v1.2.3-70-g09d2 From 5ad8f2cd5c62bb5ad5ca590fa60181e0747c6aac Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Wed, 13 Dec 2023 23:55:18 +0200 Subject: clarify some bit --- src/i18n/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/i18n') diff --git a/src/i18n/en.json b/src/i18n/en.json index ed828a62..145e1daa 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -707,7 +707,7 @@ "notification_blocks": "Blocking a user stops all notifications as well as unsubscribes them.", "enable_web_push_notifications": "Enable web push notifications", "enable_web_push_always_show": "Always show web push notifications", - "enable_web_push_always_show_tip": "Some browsers (Chromium, Chrome) require that push messages always result in a notification, otherwise generic 'Website was updated in background' is shown, enable this to prevent this notification from showing. Can result in showing duplicate notifications on other browsers.", + "enable_web_push_always_show_tip": "Some browsers (Chromium, Chrome) require that push messages always result in a notification, otherwise generic 'Website was updated in background' is shown, enable this to prevent this notification from showing, as Chrome seem to hide push notifications if tab is in focus. Can result in showing duplicate notifications on other browsers.", "more_settings": "More settings", "style": { "switcher": { -- cgit v1.2.3-70-g09d2