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 {
|
||||
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)
|
||||
}
|
||||
|
||||
func followAllSuggestedAccounts(_ dependency: NeedsDependency & AuthContextProvider) {
|
||||
func followAllSuggestedAccounts(_ dependency: NeedsDependency & AuthContextProvider, completion: (() -> Void)? = nil) {
|
||||
|
||||
let userRecords = userFetchedResultsController.records.compactMap {
|
||||
$0.object(in: dependency.context.managedObjectContext)?.asRecord
|
||||
}
|
||||
|
||||
userRecords.forEach { user in
|
||||
Task {
|
||||
try? await DataSourceFacade.responseToUserViewButtonAction(
|
||||
dependency: dependency,
|
||||
user: user,
|
||||
buttonState: .follow
|
||||
)
|
||||
}
|
||||
Task {
|
||||
await withTaskGroup(of: Void.self, body: { taskGroup in
|
||||
for user in userRecords {
|
||||
taskGroup.addTask {
|
||||
try? await DataSourceFacade.responseToUserViewButtonAction(
|
||||
dependency: dependency,
|
||||
user: user,
|
||||
buttonState: .follow
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
completion?()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue