From 0d6a9e8a647be860b10506aecaafb4ff0f10150f Mon Sep 17 00:00:00 2001
From: tusooa <tusooa@kazv.moe>
Date: Sun, 13 Aug 2023 23:57:34 -0400
Subject: Display extra notifications on notifications column

---
 src/components/notifications/notifications.vue | 7 +++++++
 1 file changed, 7 insertions(+)

(limited to 'src/components/notifications/notifications.vue')

diff --git a/src/components/notifications/notifications.vue b/src/components/notifications/notifications.vue
index 633efca6..d40c930a 100644
--- a/src/components/notifications/notifications.vue
+++ b/src/components/notifications/notifications.vue
@@ -54,6 +54,13 @@
           class="panel-body"
           role="feed"
         >
+          <div
+            v-if="showExtraNotifications"
+            role="listitem"
+            class="notification"
+          >
+            <extra-notifications />
+          </div>
           <div
             v-for="notification in notificationsToDisplay"
             :key="notification.id"
-- 
cgit v1.2.3-70-g09d2


From 50bad0fc68dee158e1681e599c7852550f5bef31 Mon Sep 17 00:00:00 2001
From: tusooa <tusooa@kazv.moe>
Date: Fri, 18 Aug 2023 21:07:48 -0400
Subject: Display unread visuals when there are unread extra notifications

---
 src/components/interactions/interactions.vue          |  1 +
 src/components/mobile_nav/mobile_nav.js               |  7 +++++--
 src/components/notifications/notifications.js         | 18 +++++++++++++++---
 src/components/notifications/notifications.vue        |  4 ++--
 src/services/notification_utils/notification_utils.js | 14 ++++++++++++++
 5 files changed, 37 insertions(+), 7 deletions(-)

(limited to 'src/components/notifications/notifications.vue')

diff --git a/src/components/interactions/interactions.vue b/src/components/interactions/interactions.vue
index b7291c02..35d03562 100644
--- a/src/components/interactions/interactions.vue
+++ b/src/components/interactions/interactions.vue
@@ -39,6 +39,7 @@
     <Notifications
       ref="notifications"
       :no-heading="true"
+      :no-extra="true"
       :minimal-mode="true"
       :filter-mode="filterMode"
     />
diff --git a/src/components/mobile_nav/mobile_nav.js b/src/components/mobile_nav/mobile_nav.js
index dad1f6aa..b5325116 100644
--- a/src/components/mobile_nav/mobile_nav.js
+++ b/src/components/mobile_nav/mobile_nav.js
@@ -1,7 +1,10 @@
 import SideDrawer from '../side_drawer/side_drawer.vue'
 import Notifications from '../notifications/notifications.vue'
 import ConfirmModal from '../confirm_modal/confirm_modal.vue'
-import { unseenNotificationsFromStore } from '../../services/notification_utils/notification_utils'
+import {
+  unseenNotificationsFromStore,
+  countExtraNotifications
+} from '../../services/notification_utils/notification_utils'
 import GestureService from '../../services/gesture_service/gesture_service'
 import NavigationPins from 'src/components/navigation/navigation_pins.vue'
 import { mapGetters } from 'vuex'
@@ -50,7 +53,7 @@ const MobileNav = {
       return unseenNotificationsFromStore(this.$store)
     },
     unseenNotificationsCount () {
-      return this.unseenNotifications.length
+      return this.unseenNotifications.length + countExtraNotifications(this.$store)
     },
     hideSitename () { return this.$store.state.instance.hideSitename },
     sitename () { return this.$store.state.instance.name },
diff --git a/src/components/notifications/notifications.js b/src/components/notifications/notifications.js
index 09ebc943..571df0f1 100644
--- a/src/components/notifications/notifications.js
+++ b/src/components/notifications/notifications.js
@@ -7,7 +7,8 @@ import notificationsFetcher from '../../services/notifications_fetcher/notificat
 import {
   notificationsFromStore,
   filteredNotificationsFromStore,
-  unseenNotificationsFromStore
+  unseenNotificationsFromStore,
+  countExtraNotifications
 } from '../../services/notification_utils/notification_utils.js'
 import FaviconService from '../../services/favicon_service/favicon_service.js'
 import { library } from '@fortawesome/fontawesome-svg-core'
@@ -33,6 +34,11 @@ const Notifications = {
     minimalMode: Boolean,
     // Custom filter mode, an array of strings, possible values 'mention', 'repeat', 'like', 'follow', used to override global filter for use in "Interactions" timeline
     filterMode: Array,
+    // Do not show extra notifications
+    noExtra: {
+      type: Boolean,
+      default: false
+    },
     // Disable teleporting (i.e. for /users/user/notifications)
     disableTeleport: Boolean
   },
@@ -67,11 +73,17 @@ const Notifications = {
     filteredNotifications () {
       return filteredNotificationsFromStore(this.$store, this.filterMode)
     },
+    unseenCountBadgeText () {
+      return `${this.unseenCount ? this.unseenCount : ''}${this.extraNotificationsCount ? '*' : ''}`
+    },
     unseenCount () {
       return this.unseenNotifications.length
     },
+    extraNotificationsCount () {
+      return countExtraNotifications(this.$store)
+    },
     unseenCountTitle () {
-      return this.unseenCount + (this.unreadChatCount) + this.unreadAnnouncementCount
+      return this.unseenNotifications.length + (this.unreadChatCount) + this.unreadAnnouncementCount
     },
     loading () {
       return this.$store.state.statuses.notifications.loading
@@ -97,7 +109,7 @@ const Notifications = {
     },
     noSticky () { return this.$store.getters.mergedConfig.disableStickyHeaders },
     showExtraNotifications () {
-      return !this.noHeading
+      return !this.noExtra
     },
     ...mapGetters(['unreadChatCount', 'unreadAnnouncementCount'])
   },
diff --git a/src/components/notifications/notifications.vue b/src/components/notifications/notifications.vue
index d40c930a..999f8e9c 100644
--- a/src/components/notifications/notifications.vue
+++ b/src/components/notifications/notifications.vue
@@ -17,9 +17,9 @@
           <div class="title">
             {{ $t('notifications.notifications') }}
             <span
-              v-if="unseenCount"
+              v-if="unseenCountBadgeText"
               class="badge badge-notification unseen-count"
-            >{{ unseenCount }}</span>
+            >{{ unseenCountBadgeText }}</span>
           </div>
           <div
             v-if="showScrollTop"
diff --git a/src/services/notification_utils/notification_utils.js b/src/services/notification_utils/notification_utils.js
index 0f8b9b02..815e792d 100644
--- a/src/services/notification_utils/notification_utils.js
+++ b/src/services/notification_utils/notification_utils.js
@@ -124,3 +124,17 @@ export const prepareNotificationObject = (notification, i18n) => {
 
   return notifObj
 }
+
+export const countExtraNotifications = (store) => {
+  const mergedConfig = store.getters.mergedConfig
+
+  if (!mergedConfig.showExtraNotifications) {
+    return 0
+  }
+
+  return [
+    mergedConfig.showChatsInExtraNotifications ? store.getters.unreadChatCount : 0,
+    mergedConfig.showAnnouncementsInExtraNotifications ? store.getters.unreadAnnouncementCount : 0,
+    mergedConfig.showFollowRequestsInExtraNotifications ? store.getters.followRequestCount : 0
+  ].reduce((a, c) => a + c, 0)
+}
-- 
cgit v1.2.3-70-g09d2

