Fix media selection undo

This commit is contained in:
Ilya Laktyushin
2022-07-26 03:07:41 +03:00
parent dcdb3a44a7
commit 689a5e0427

View File

@@ -1259,7 +1259,11 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
if let undoOverlayController = strongSelf.undoOverlayController {
undoOverlayController.content = .image(image: image ?? UIImage(), text: text)
} else {
let undoOverlayController = UndoOverlayController(presentationData: presentationData, content: .image(image: image ?? UIImage(), text: text), elevatedLayout: false, action: { [weak self] action in
var elevatedLayout = true
if let layout = strongSelf.validLayout, case .regular = layout.metrics.widthClass {
elevatedLayout = false
}
let undoOverlayController = UndoOverlayController(presentationData: presentationData, content: .image(image: image ?? UIImage(), text: text), elevatedLayout: elevatedLayout, action: { [weak self] action in
guard let strongSelf = self else {
return true
}
@@ -1271,7 +1275,11 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
}
return true
})
strongSelf.present(undoOverlayController, in: .current)
if let layout = strongSelf.validLayout, case .regular = layout.metrics.widthClass {
strongSelf.present(undoOverlayController, in: .current)
} else {
strongSelf.present(undoOverlayController, in: .window(.root))
}
strongSelf.undoOverlayController = undoOverlayController
}
})