Inverse hellthread_notifications_enabled to be hellthread_notifications_disabled and add hellthread_notifications_max_pubkeys setting
Signed-off-by: Terry Yiu <git@tyiu.xyz>
This commit is contained in:
@@ -10,16 +10,26 @@ import SwiftUI
|
||||
class NotificationFilter: ObservableObject, Equatable {
|
||||
@Published var state: NotificationFilterState
|
||||
@Published var friend_filter: FriendFilter
|
||||
@Published var show_hellthreads: Bool = false
|
||||
@Published var hellthread_notifications_disabled: Bool
|
||||
@Published var hellthread_notification_max_pubkeys: Int
|
||||
|
||||
static func == (lhs: NotificationFilter, rhs: NotificationFilter) -> Bool {
|
||||
return lhs.state == rhs.state && lhs.friend_filter == rhs.friend_filter && lhs.show_hellthreads == rhs.show_hellthreads
|
||||
return lhs.state == rhs.state
|
||||
&& lhs.friend_filter == rhs.friend_filter
|
||||
&& lhs.hellthread_notifications_disabled == rhs.hellthread_notifications_disabled
|
||||
&& lhs.hellthread_notification_max_pubkeys == rhs.hellthread_notification_max_pubkeys
|
||||
}
|
||||
|
||||
init(state: NotificationFilterState = .all, friend_filter: FriendFilter = .all, show_hellthreads: Bool = false) {
|
||||
init(
|
||||
state: NotificationFilterState = .all,
|
||||
friend_filter: FriendFilter = .all,
|
||||
hellthread_notifications_disabled: Bool = false,
|
||||
hellthread_notification_max_pubkeys: Int = DEFAULT_HELLTHREAD_MAX_PUBKEYS
|
||||
) {
|
||||
self.state = state
|
||||
self.friend_filter = friend_filter
|
||||
self.show_hellthreads = show_hellthreads
|
||||
self.hellthread_notifications_disabled = hellthread_notifications_disabled
|
||||
self.hellthread_notification_max_pubkeys = hellthread_notification_max_pubkeys
|
||||
}
|
||||
|
||||
func filter(contacts: Contacts, items: [NotificationItem]) -> [NotificationItem] {
|
||||
@@ -31,7 +41,7 @@ class NotificationFilter: ObservableObject, Equatable {
|
||||
|
||||
if let item = item.filter({ ev in
|
||||
self.friend_filter.filter(contacts: contacts, pubkey: ev.pubkey) &&
|
||||
(show_hellthreads || !ev.is_hellthread)
|
||||
(!hellthread_notifications_disabled || !ev.is_hellthread(max_pubkeys: hellthread_notification_max_pubkeys))
|
||||
}) {
|
||||
acc.append(item)
|
||||
}
|
||||
@@ -71,7 +81,8 @@ struct NotificationsView: View {
|
||||
NotificationFilter(
|
||||
state: .all,
|
||||
friend_filter: filter.friend_filter,
|
||||
show_hellthreads: state.settings.hellthread_notification
|
||||
hellthread_notifications_disabled: state.settings.hellthread_notifications_disabled,
|
||||
hellthread_notification_max_pubkeys: state.settings.hellthread_notification_max_pubkeys
|
||||
)
|
||||
)
|
||||
.tag(NotificationFilterState.all)
|
||||
@@ -80,7 +91,8 @@ struct NotificationsView: View {
|
||||
NotificationFilter(
|
||||
state: .zaps,
|
||||
friend_filter: filter.friend_filter,
|
||||
show_hellthreads: state.settings.hellthread_notification
|
||||
hellthread_notifications_disabled: state.settings.hellthread_notifications_disabled,
|
||||
hellthread_notification_max_pubkeys: state.settings.hellthread_notification_max_pubkeys
|
||||
)
|
||||
)
|
||||
.tag(NotificationFilterState.zaps)
|
||||
@@ -89,7 +101,8 @@ struct NotificationsView: View {
|
||||
NotificationFilter(
|
||||
state: .replies,
|
||||
friend_filter: filter.friend_filter,
|
||||
show_hellthreads: state.settings.hellthread_notification
|
||||
hellthread_notifications_disabled: state.settings.hellthread_notifications_disabled,
|
||||
hellthread_notification_max_pubkeys: state.settings.hellthread_notification_max_pubkeys
|
||||
)
|
||||
)
|
||||
.tag(NotificationFilterState.replies)
|
||||
|
||||
Reference in New Issue
Block a user