Dismiss after following all (IOS-157)
This commit is contained in:
parent
9c19bf2985
commit
5daf944384
|
@ -122,7 +122,11 @@ extension SuggestionAccountViewController: SuggestionAccountTableViewCellDelegat
|
||||||
|
|
||||||
extension SuggestionAccountViewController: SuggestionAccountTableViewFooterDelegate {
|
extension SuggestionAccountViewController: SuggestionAccountTableViewFooterDelegate {
|
||||||
func followAll(_ footerView: SuggestionAccountTableViewFooter) {
|
func followAll(_ footerView: SuggestionAccountTableViewFooter) {
|
||||||
viewModel.followAllSuggestedAccounts(self)
|
viewModel.followAllSuggestedAccounts(self) {
|
||||||
|
OperationQueue.main.addOperation {
|
||||||
|
self.dismiss(animated: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,20 +114,26 @@ final class SuggestionAccountViewModel: NSObject {
|
||||||
.store(in: &disposeBag)
|
.store(in: &disposeBag)
|
||||||
}
|
}
|
||||||
|
|
||||||
func followAllSuggestedAccounts(_ dependency: NeedsDependency & AuthContextProvider) {
|
func followAllSuggestedAccounts(_ dependency: NeedsDependency & AuthContextProvider, completion: (() -> Void)? = nil) {
|
||||||
|
|
||||||
let userRecords = userFetchedResultsController.records.compactMap {
|
let userRecords = userFetchedResultsController.records.compactMap {
|
||||||
$0.object(in: dependency.context.managedObjectContext)?.asRecord
|
$0.object(in: dependency.context.managedObjectContext)?.asRecord
|
||||||
}
|
}
|
||||||
|
|
||||||
userRecords.forEach { user in
|
Task {
|
||||||
Task {
|
await withTaskGroup(of: Void.self, body: { taskGroup in
|
||||||
try? await DataSourceFacade.responseToUserViewButtonAction(
|
for user in userRecords {
|
||||||
dependency: dependency,
|
taskGroup.addTask {
|
||||||
user: user,
|
try? await DataSourceFacade.responseToUserViewButtonAction(
|
||||||
buttonState: .follow
|
dependency: dependency,
|
||||||
)
|
user: user,
|
||||||
}
|
buttonState: .follow
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
completion?()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue