added some settings for notifications

This commit is contained in:
Henry Jameson 2023-11-19 15:24:34 +02:00
parent 2f90c629b8
commit e3ee3eacca
8 changed files with 76 additions and 7 deletions

View File

@ -14,7 +14,8 @@ import {
faBell, faBell,
faBars, faBars,
faArrowUp, faArrowUp,
faMinus faMinus,
faCheckDouble
} from '@fortawesome/free-solid-svg-icons' } from '@fortawesome/free-solid-svg-icons'
library.add( library.add(
@ -22,7 +23,8 @@ library.add(
faBell, faBell,
faBars, faBars,
faArrowUp, faArrowUp,
faMinus faMinus,
faCheckDouble
) )
const MobileNav = { const MobileNav = {
@ -67,6 +69,9 @@ const MobileNav = {
shouldConfirmLogout () { shouldConfirmLogout () {
return this.$store.getters.mergedConfig.modalOnLogout return this.$store.getters.mergedConfig.modalOnLogout
}, },
closingDrawerMarksAsSeen () {
return this.$store.getters.mergedConfig.closingDrawerMarksAsSeen
},
...mapGetters(['unreadChatCount']) ...mapGetters(['unreadChatCount'])
}, },
methods: { methods: {

View File

@ -66,6 +66,17 @@
/> />
</FALayers> </FALayers>
</button> </button>
<button
v-if="!closingDrawerMarksAsSeen"
class="button-unstyled mobile-nav-button"
:title="$t('nav.mobile_notifications_close')"
@click.stop.prevent="markNotificationsAsSeen()"
>
<FAIcon
class="fa-scale-110 fa-old-padding"
icon="check-double"
/>
</button>
<button <button
class="button-unstyled mobile-nav-button" class="button-unstyled mobile-nav-button"
:title="$t('nav.mobile_notifications_close')" :title="$t('nav.mobile_notifications_close')"

View File

@ -21,6 +21,7 @@ library.add(
) )
const DEFAULT_SEEN_TO_DISPLAY_COUNT = 30 const DEFAULT_SEEN_TO_DISPLAY_COUNT = 30
const ACTIONABLE_NOTIFICATION_TYPES = new Set(['mention', 'pleroma:report', 'follow_request'])
const Notifications = { const Notifications = {
components: { components: {
@ -71,14 +72,26 @@ const Notifications = {
return unseenNotificationsFromStore(this.$store) return unseenNotificationsFromStore(this.$store)
}, },
filteredNotifications () { filteredNotifications () {
if (this.unseenAtTop) {
return [
...filteredNotificationsFromStore(this.$store).filter(n => this.shouldShowUnseen(n)),
...filteredNotificationsFromStore(this.$store).filter(n => !this.shouldShowUnseen(n))
]
} else {
return filteredNotificationsFromStore(this.$store, this.filterMode) return filteredNotificationsFromStore(this.$store, this.filterMode)
}
}, },
unseenCountBadgeText () { unseenCountBadgeText () {
return `${this.unseenCount ? this.unseenCount : ''}${this.extraNotificationsCount ? '*' : ''}` return `${this.unseenCount ? this.unseenCount : ''}${this.extraNotificationsCount ? '*' : ''}`
}, },
unseenCount () { unseenCount () {
if (this.ignoreInactionableSeen) {
return this.unseenNotifications.filter(n => ACTIONABLE_NOTIFICATION_TYPES.has(n.type)).length
} else {
return this.unseenNotifications.length return this.unseenNotifications.length
}
}, },
ignoreInactionableSeen () { return this.$store.getters.mergedConfig.ignoreInactionableSeen },
extraNotificationsCount () { extraNotificationsCount () {
return countExtraNotifications(this.$store) return countExtraNotifications(this.$store)
}, },
@ -108,6 +121,7 @@ const Notifications = {
return this.filteredNotifications.slice(0, this.unseenCount + this.seenToDisplayCount) return this.filteredNotifications.slice(0, this.unseenCount + this.seenToDisplayCount)
}, },
noSticky () { return this.$store.getters.mergedConfig.disableStickyHeaders }, noSticky () { return this.$store.getters.mergedConfig.disableStickyHeaders },
unseenAtTop () { return this.$store.getters.mergedConfig.unseenAtTop },
showExtraNotifications () { showExtraNotifications () {
return !this.noExtra return !this.noExtra
}, },
@ -154,11 +168,16 @@ const Notifications = {
scrollToTop () { scrollToTop () {
const scrollable = this.scrollerRef const scrollable = this.scrollerRef
scrollable.scrollTo({ top: this.$refs.root.offsetTop }) scrollable.scrollTo({ top: this.$refs.root.offsetTop })
// this.$refs.root.scrollIntoView({ behavior: 'smooth', block: 'start' })
}, },
updateScrollPosition () { updateScrollPosition () {
this.showScrollTop = this.$refs.root.offsetTop < this.scrollerRef.scrollTop this.showScrollTop = this.$refs.root.offsetTop < this.scrollerRef.scrollTop
}, },
shouldShowUnseen (notification) {
if (notification.seen) return false
const actionable = ACTIONABLE_NOTIFICATION_TYPES.has(notification.type)
return this.ignoreInactionableSeen ? actionable : true
},
/* "Interacted" really refers to "actionable" notifications that require user input, /* "Interacted" really refers to "actionable" notifications that require user input,
* everything else (likes/repeats/reacts) cannot be acted and therefore we just clear * everything else (likes/repeats/reacts) cannot be acted and therefore we just clear
* the "seen" status upon any clicks on them * the "seen" status upon any clicks on them

View File

@ -66,7 +66,7 @@
:key="notification.id" :key="notification.id"
role="listitem" role="listitem"
class="notification" class="notification"
:class="{unseen: !minimalMode && !notification.seen}" :class="{unseen: !minimalMode && shouldShowUnseen(notification)}"
@click="e => notificationClicked(notification)" @click="e => notificationClicked(notification)"
> >
<div class="notification-overlay" /> <div class="notification-overlay" />

View File

@ -1,5 +1,28 @@
<template> <template>
<div :label="$t('settings.notifications')"> <div :label="$t('settings.notifications')">
<div class="setting-item">
<h2>{{ $t('settings.notification_setting_annoyance') }}</h2>
<ul class="setting-list">
<li>
<BooleanSetting path="closingDrawerMarksAsSeen">
{{ $t('settings.notification_setting_drawer_marks_as_seen') }}
</BooleanSetting>
</li>
<li>
<BooleanSetting path="ignoreInactionableSeen">
{{ $t('settings.notification_setting_ignore_inactionable_seen') }}
</BooleanSetting>
<p>
{{ $t('settings.notification_setting_ignore_inactionable_seen_tip') }}
</p>
</li>
<li>
<BooleanSetting path="unseenAtTop">
{{ $t('settings.notification_setting_unseen_at_top') }}
</BooleanSetting>
</li>
</ul>
</div>
<div class="setting-item"> <div class="setting-item">
<h2>{{ $t('settings.notification_setting_filters') }}</h2> <h2>{{ $t('settings.notification_setting_filters') }}</h2>
<ul class="setting-list"> <ul class="setting-list">

View File

@ -688,6 +688,11 @@
"greentext": "Meme arrows", "greentext": "Meme arrows",
"show_yous": "Show (You)s", "show_yous": "Show (You)s",
"notifications": "Notifications", "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_filters": "Filters",
"notification_setting_block_from_strangers": "Block notifications from users who you do not follow", "notification_setting_block_from_strangers": "Block notifications from users who you do not follow",
"notification_setting_privacy": "Privacy", "notification_setting_privacy": "Privacy",

View File

@ -127,7 +127,10 @@ export const defaultState = {
showAnnouncementsInExtraNotifications: undefined, // instance default showAnnouncementsInExtraNotifications: undefined, // instance default
showFollowRequestsInExtraNotifications: undefined, // instance default showFollowRequestsInExtraNotifications: undefined, // instance default
maxDepthInThread: undefined, // instance default maxDepthInThread: undefined, // instance default
autocompleteSelect: undefined // instance default autocompleteSelect: undefined, // instance default
closingDrawerMarksAsSeen: undefined, // instance default
unseenAtTop: undefined, // instance default
ignoreInactionableSeen: undefined // instance default
} }
// caching the instance default properties // caching the instance default properties

View File

@ -110,6 +110,9 @@ const defaultState = {
showFollowRequestsInExtraNotifications: true, showFollowRequestsInExtraNotifications: true,
maxDepthInThread: 6, maxDepthInThread: 6,
autocompleteSelect: false, autocompleteSelect: false,
closingDrawerMarksAsSeen: true,
unseenAtTop: false,
ignoreInactionableSeen: false,
// Nasty stuff // Nasty stuff
customEmoji: [], customEmoji: [],