Skip to content

Commit

Permalink
Revert all DismissAction usages
Browse files Browse the repository at this point in the history
Using `@Environment(\.dismiss) private var dismiss` apparently hits some
SwiftUI bug or somesuch leading to endless loops in the main thread.

Using `@Environment(\.presentationMode) private var presentationMode` is
fine, though --> revert everthing to use presentationMode.

Revert "Use DismissAction in ContactDetails"
This reverts commit 3f8c806.

Revert "Use DismissAction in AddTopLevelNavigation"
This reverts commit cfdfbfb.

Revert "Use DismissAction in EditGroupSubject"
This reverts commit 26d64a8.

Revert "Use DismissAction in ImageCropView"
This reverts commit e0e7943.
  • Loading branch information
tmolitor-stud-tu committed Sep 14, 2024
1 parent 9cff539 commit bd4e00f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Monal/Classes/ContactDetails.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

struct ContactDetails: View {
@Environment(\.dismiss) private var dismiss
@Environment(\.presentationMode) private var presentationMode
@State private var ownRole = kMucRoleParticipant
@State private var ownAffiliation = kMucAffiliationNone
@StateObject var contact: ObservableKVOWrapper<MLContact>
Expand Down Expand Up @@ -490,7 +490,7 @@ struct ContactDetails: View {
if let delegate = self.delegate {
delegate.dismiss()
} else {
self.dismiss()
self.presentationMode.wrappedValue.dismiss()
}
}
)
Expand Down
7 changes: 3 additions & 4 deletions Monal/Classes/EditGroupSubject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ struct EditGroupSubject: View {
private let account: xmpp?
@State private var subject: String

@Environment(\.dismiss) var dismiss
//@Environment(\.dismiss) var dismiss
@Environment(\.presentationMode) var presentationMode

init(contact: ObservableKVOWrapper<MLContact>) {
MLAssert(contact.isMuc, "contact must be a muc")
Expand All @@ -37,13 +36,13 @@ struct EditGroupSubject: View {
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button("Abort") {
self.dismiss()
self.presentationMode.wrappedValue.dismiss()
}
}
ToolbarItem(placement: .confirmationAction) {
Button("Done") {
self.account!.mucProcessor.changeSubject(ofMuc: contact.contactJid, to: self.subject)
self.dismiss()
self.presentationMode.wrappedValue.dismiss()
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions Monal/Classes/SwiftuiHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public struct ImageCropView: UIViewControllerRepresentable {
private let onCanceled: () -> Void
private let onImageCropped: (UIImage,CGRect,Int) -> Void

@Environment(\.dismiss) private var dismiss
@Environment(\.presentationMode) private var presentationMode

public init(originalImage: UIImage, configureBlock: @escaping (CropViewController) -> Void, onCanceled: @escaping () -> Void, success onImageCropped: @escaping (UIImage,CGRect,Int) -> Void) {
self.originalImage = originalImage
Expand All @@ -261,7 +261,7 @@ public struct ImageCropView: UIViewControllerRepresentable {

public func makeCoordinator() -> Coordinator {
Coordinator(
onDismiss: { self.dismiss() },
onDismiss: { self.presentationMode.wrappedValue.dismiss() },
onCanceled: self.onCanceled,
onImageCropped: self.onImageCropped
)
Expand Down Expand Up @@ -555,7 +555,7 @@ struct LazyClosureView<Content: View>: View {

// use this to wrap a view into NavigationStack, if it should be the outermost swiftui view of a new view stack
struct AddTopLevelNavigation<Content: View>: View {
@Environment(\.dismiss) private var dismiss
@Environment(\.presentationMode) private var presentationMode
@StateObject private var sizeClass: ObservableKVOWrapper<SizeClassWrapper>
let build: () -> Content
let delegate: SheetDismisserProtocol?
Expand Down Expand Up @@ -586,7 +586,7 @@ struct AddTopLevelNavigation<Content: View>: View {
if let delegate = self.delegate {
delegate.dismiss()
} else {
self.dismiss()
self.presentationMode.wrappedValue.dismiss()
}
}) {
Image(systemName: "arrow.backward")
Expand Down

0 comments on commit bd4e00f

Please sign in to comment.