mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Prevent multiple file selection callbacks coming from the media upload pickers and generating incorrect transitions in the RoomFlowCoordinator state machine
This commit is contained in:
committed by
Stefan Ceriu
parent
1bbb077e3e
commit
ea91e371eb
@@ -29,9 +29,11 @@ enum PhotoLibraryPickerError: Error {
|
||||
}
|
||||
|
||||
struct PhotoLibraryPicker: UIViewControllerRepresentable {
|
||||
private weak var userIndicatorController: UserIndicatorControllerProtocol?
|
||||
private let callback: (PhotoLibraryPickerAction) -> Void
|
||||
|
||||
init(callback: @escaping (PhotoLibraryPickerAction) -> Void) {
|
||||
init(userIndicatorController: UserIndicatorControllerProtocol?, callback: @escaping (PhotoLibraryPickerAction) -> Void) {
|
||||
self.userIndicatorController = userIndicatorController
|
||||
self.callback = callback
|
||||
}
|
||||
|
||||
@@ -60,6 +62,8 @@ struct PhotoLibraryPicker: UIViewControllerRepresentable {
|
||||
|
||||
// MARK: PHPickerViewControllerDelegate
|
||||
|
||||
private static let loadingIndicatorIdentifier = "PhotoLibraryPickerLoadingIndicator"
|
||||
|
||||
func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
|
||||
guard let provider = results.first?.itemProvider,
|
||||
let contentType = provider.preferredContentType else {
|
||||
@@ -67,6 +71,13 @@ struct PhotoLibraryPicker: UIViewControllerRepresentable {
|
||||
return
|
||||
}
|
||||
|
||||
picker.delegate = nil
|
||||
|
||||
photoLibraryPicker.userIndicatorController?.submitIndicator(UserIndicator(id: Self.loadingIndicatorIdentifier, type: .modal, title: L10n.commonLoading))
|
||||
defer {
|
||||
photoLibraryPicker.userIndicatorController?.retractIndicatorWithId(Self.loadingIndicatorIdentifier)
|
||||
}
|
||||
|
||||
provider.loadFileRepresentation(forTypeIdentifier: contentType.identifier) { [weak self] url, error in
|
||||
guard let url else {
|
||||
Task { @MainActor in
|
||||
|
||||
Reference in New Issue
Block a user