Don't initialize camera on attach menu appearance if effects are disabled

This commit is contained in:
Ilya Laktyushin 2023-03-09 23:50:37 +04:00
parent a65d7bba8f
commit b39238c6db

View File

@ -408,17 +408,26 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
} }
if let controller = self.controller, case .assets(nil) = controller.subject { if let controller = self.controller, case .assets(nil) = controller.subject {
let enableAnimations = self.controller?.context.sharedContext.energyUsageSettings.fullTranslucency ?? true
let cameraView = TGAttachmentCameraView(forSelfPortrait: false, videoModeByDefault: controller.bannedSendPhotos != nil && controller.bannedSendVideos == nil)! let cameraView = TGAttachmentCameraView(forSelfPortrait: false, videoModeByDefault: controller.bannedSendPhotos != nil && controller.bannedSendVideos == nil)!
cameraView.clipsToBounds = true cameraView.clipsToBounds = true
cameraView.removeCorners() cameraView.removeCorners()
cameraView.pressed = { [weak self] in cameraView.pressed = { [weak self, weak cameraView] in
if let strongSelf = self, !strongSelf.openingMedia { if let strongSelf = self, !strongSelf.openingMedia {
strongSelf.dismissInput() strongSelf.dismissInput()
strongSelf.controller?.openCamera?(strongSelf.cameraView) strongSelf.controller?.openCamera?(strongSelf.cameraView)
if !enableAnimations {
cameraView?.startPreview()
}
} }
} }
self.cameraView = cameraView self.cameraView = cameraView
cameraView.startPreview()
if enableAnimations {
cameraView.startPreview()
}
self.gridNode.scrollView.addSubview(cameraView) self.gridNode.scrollView.addSubview(cameraView)
self.gridNode.addSubnode(self.cameraActivateAreaNode) self.gridNode.addSubnode(self.cameraActivateAreaNode)