mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Merge commit '8c2a06a3c81d901f9eadee42a7b32b1f16785aad'
This commit is contained in:
commit
befaf0e640
@ -38,6 +38,8 @@ protocol MediaEditorVideoExportWriter {
|
||||
func markAudioAsFinished()
|
||||
|
||||
var status: ExportWriterStatus { get }
|
||||
|
||||
var error: Error? { get }
|
||||
}
|
||||
|
||||
public final class MediaEditorVideoAVAssetWriter: MediaEditorVideoExportWriter {
|
||||
@ -178,6 +180,10 @@ public final class MediaEditorVideoAVAssetWriter: MediaEditorVideoExportWriter {
|
||||
return .unknown
|
||||
}
|
||||
}
|
||||
|
||||
var error: Error? {
|
||||
return self.writer?.error
|
||||
}
|
||||
}
|
||||
|
||||
public final class MediaEditorVideoExport {
|
||||
@ -295,6 +301,10 @@ public final class MediaEditorVideoExport {
|
||||
self.configuration = configuration
|
||||
self.outputPath = outputPath
|
||||
|
||||
if FileManager.default.fileExists(atPath: outputPath) {
|
||||
try? FileManager.default.removeItem(atPath: outputPath)
|
||||
}
|
||||
|
||||
self.setup()
|
||||
|
||||
let _ = NotificationCenter.default.addObserver(forName: UIApplication.willEnterForegroundNotification, object: nil, queue: nil, using: { [weak self] _ in
|
||||
@ -493,10 +503,16 @@ public final class MediaEditorVideoExport {
|
||||
}
|
||||
|
||||
if writer.status == .failed {
|
||||
if let error = writer.error {
|
||||
Logger.shared.log("VideoExport", "Failed with writer error \(error.localizedDescription)")
|
||||
}
|
||||
try? FileManager().removeItem(at: outputUrl)
|
||||
self.internalStatus = .finished
|
||||
self.statusValue = .failed(.writing(nil))
|
||||
} else if let reader = self.reader, reader.status == .failed {
|
||||
if let error = reader.error {
|
||||
Logger.shared.log("VideoExport", "Failed with reader error \(error.localizedDescription)")
|
||||
}
|
||||
try? FileManager().removeItem(at: outputUrl)
|
||||
writer.cancelWriting()
|
||||
self.internalStatus = .finished
|
||||
@ -505,6 +521,9 @@ public final class MediaEditorVideoExport {
|
||||
writer.finishWriting {
|
||||
self.queue.async {
|
||||
if writer.status == .failed {
|
||||
if let error = writer.error {
|
||||
Logger.shared.log("VideoExport", "Failed after finishWriting with writer error \(error.localizedDescription)")
|
||||
}
|
||||
try? FileManager().removeItem(at: outputUrl)
|
||||
self.internalStatus = .finished
|
||||
self.statusValue = .failed(.writing(nil))
|
||||
|
@ -3092,6 +3092,8 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
|
||||
}
|
||||
|
||||
func openPrivacySettings(_ privacy: MediaEditorResultPrivacy? = nil, completion: @escaping () -> Void = {}) {
|
||||
self.node.mediaEditor?.stop()
|
||||
|
||||
self.hapticFeedback.impact(.light)
|
||||
|
||||
let privacy = privacy ?? self.state.privacy
|
||||
@ -3103,39 +3105,42 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
|
||||
}
|
||||
let initialPrivacy = privacy.privacy
|
||||
let timeout = privacy.timeout
|
||||
self.push(
|
||||
ShareWithPeersScreen(
|
||||
context: self.context,
|
||||
initialPrivacy: initialPrivacy,
|
||||
allowScreenshots: !privacy.isForwardingDisabled,
|
||||
pin: privacy.pin,
|
||||
timeout: privacy.timeout,
|
||||
stateContext: stateContext,
|
||||
completion: { [weak self] privacy, allowScreenshots, pin in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
self.state.privacy = MediaEditorResultPrivacy(privacy: privacy, timeout: timeout, isForwardingDisabled: !allowScreenshots, pin: pin)
|
||||
completion()
|
||||
},
|
||||
editCategory: { [weak self] privacy, allowScreenshots, pin in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
self.openEditCategory(privacy: privacy, isForwardingDisabled: !allowScreenshots, pin: pin, completion: { [weak self] privacy in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
self.openPrivacySettings(MediaEditorResultPrivacy(
|
||||
privacy: privacy,
|
||||
timeout: timeout,
|
||||
isForwardingDisabled: !allowScreenshots,
|
||||
pin: pin
|
||||
), completion: completion)
|
||||
})
|
||||
|
||||
let controller = ShareWithPeersScreen(
|
||||
context: self.context,
|
||||
initialPrivacy: initialPrivacy,
|
||||
allowScreenshots: !privacy.isForwardingDisabled,
|
||||
pin: privacy.pin,
|
||||
timeout: privacy.timeout,
|
||||
stateContext: stateContext,
|
||||
completion: { [weak self] privacy, allowScreenshots, pin in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
)
|
||||
self.state.privacy = MediaEditorResultPrivacy(privacy: privacy, timeout: timeout, isForwardingDisabled: !allowScreenshots, pin: pin)
|
||||
completion()
|
||||
},
|
||||
editCategory: { [weak self] privacy, allowScreenshots, pin in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
self.openEditCategory(privacy: privacy, isForwardingDisabled: !allowScreenshots, pin: pin, completion: { [weak self] privacy in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
self.openPrivacySettings(MediaEditorResultPrivacy(
|
||||
privacy: privacy,
|
||||
timeout: timeout,
|
||||
isForwardingDisabled: !allowScreenshots,
|
||||
pin: pin
|
||||
), completion: completion)
|
||||
})
|
||||
}
|
||||
)
|
||||
controller.dismissed = {
|
||||
self.node.mediaEditor?.play()
|
||||
}
|
||||
self.push(controller)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -479,7 +479,7 @@ final class ShareWithPeersScreenComponent: Component {
|
||||
self.dismissPanState = nil
|
||||
|
||||
if translation.y > 100.0 || velocity.y > 10.0 {
|
||||
controller.dismiss()
|
||||
controller.requestDismiss()
|
||||
} else {
|
||||
self.state?.updated(transition: Transition(animation: .curve(duration: 0.3, curve: .spring)))
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user