poll subscriptions more reactively
This commit is contained in:
parent
049f194304
commit
0a968eb191
1 changed files with 12 additions and 6 deletions
|
|
@ -19,18 +19,14 @@ struct SubscriptionListView: View {
|
|||
if #available(iOS 15.0, *) {
|
||||
subscriptionList
|
||||
.refreshable {
|
||||
subscriptionsModel.subscriptions.forEach { subscription in
|
||||
subscriptionManager.poll(subscription)
|
||||
}
|
||||
pollSubscriptions()
|
||||
}
|
||||
} else {
|
||||
subscriptionList
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
Button {
|
||||
subscriptionsModel.subscriptions.forEach { subscription in
|
||||
subscriptionManager.poll(subscription)
|
||||
}
|
||||
pollSubscriptions()
|
||||
} label: {
|
||||
Image(systemName: "arrow.clockwise")
|
||||
}
|
||||
|
|
@ -81,6 +77,16 @@ struct SubscriptionListView: View {
|
|||
.sheet(isPresented: $showingAddDialog) {
|
||||
SubscriptionAddView(isShowing: $showingAddDialog)
|
||||
}
|
||||
.onAppear {
|
||||
// Ensures subscription count stays up to date, so a pull to refresh isn't required
|
||||
pollSubscriptions()
|
||||
}
|
||||
}
|
||||
|
||||
private func pollSubscriptions() {
|
||||
subscriptionsModel.subscriptions.forEach { subscription in
|
||||
subscriptionManager.poll(subscription)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue