mirror of
https://github.com/yattee/yattee.git
synced 2026-02-19 09:19:46 +00:00
Add Enable All / Disable All menu to channel notifications settings
This commit is contained in:
@@ -11354,6 +11354,28 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"settings.notifications.disableAll" : {
|
||||
"comment" : "Button to disable notifications for all channels",
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Disable All"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"settings.notifications.enableAll" : {
|
||||
"comment" : "Button to enable notifications for all channels",
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Enable All"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"settings.notifications.noSubscriptions.description" : {
|
||||
"comment" : "Description when no subscriptions exist",
|
||||
"localizations" : {
|
||||
|
||||
@@ -160,6 +160,7 @@ struct ManageChannelNotificationsView: View {
|
||||
@State private var subscriptions: [Subscription] = []
|
||||
@State private var isLoading = false
|
||||
@State private var errorMessage: String?
|
||||
@State private var refreshID = UUID()
|
||||
|
||||
private var subscriptionService: SubscriptionService? { appEnvironment?.subscriptionService }
|
||||
|
||||
@@ -194,17 +195,46 @@ struct ManageChannelNotificationsView: View {
|
||||
ForEach(subscriptions, id: \.channelID) { subscription in
|
||||
ChannelNotificationToggle(subscription: subscription)
|
||||
}
|
||||
.id(refreshID)
|
||||
}
|
||||
}
|
||||
.navigationTitle(String(localized: "settings.notifications.manageChannels.title"))
|
||||
#if os(iOS)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
#endif
|
||||
.toolbar {
|
||||
if !subscriptions.isEmpty {
|
||||
ToolbarItem(placement: .primaryAction) {
|
||||
Menu {
|
||||
Button {
|
||||
setAllNotifications(enabled: true)
|
||||
} label: {
|
||||
Label(String(localized: "settings.notifications.enableAll"), systemImage: "bell.fill")
|
||||
}
|
||||
Button {
|
||||
setAllNotifications(enabled: false)
|
||||
} label: {
|
||||
Label(String(localized: "settings.notifications.disableAll"), systemImage: "bell.slash")
|
||||
}
|
||||
} label: {
|
||||
Image(systemName: "ellipsis.circle")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.task {
|
||||
await loadSubscriptionsAsync()
|
||||
}
|
||||
}
|
||||
|
||||
private func setAllNotifications(enabled: Bool) {
|
||||
guard let dataManager = appEnvironment?.dataManager else { return }
|
||||
for subscription in subscriptions {
|
||||
dataManager.setNotificationsEnabled(enabled, for: subscription.channelID)
|
||||
}
|
||||
refreshID = UUID()
|
||||
}
|
||||
|
||||
/// Loads subscriptions from the current subscription account provider.
|
||||
/// For local accounts, loads from DataManager.
|
||||
/// For Invidious/Piped accounts, fetches from the respective API.
|
||||
|
||||
Reference in New Issue
Block a user