Refactoring [skip ci]

This commit is contained in:
Ali
2023-04-19 23:47:38 +04:00
parent 61b95461d5
commit 6a548e11a6
277 changed files with 613 additions and 19657 deletions

View File

@@ -13,7 +13,6 @@ import AppBundle
import LegacyMediaPickerUI
import AVFoundation
import UndoUI
import Postbox
private struct NotificationSoundSelectionArguments {
let account: Account
@@ -516,20 +515,20 @@ public func presentCustomNotificationSoundFilePicker(context: AccountContext, co
let fileName = url.lastPathComponent
var maybeUrl: URL?
let tempFile = TempBox.shared.tempFile(fileName: "file.mp3")
let tempFile = EngineTempBox.shared.tempFile(fileName: "file.mp3")
do {
try FileManager.default.copyItem(at: url, to: URL(fileURLWithPath: tempFile.path))
maybeUrl = URL(fileURLWithPath: tempFile.path)
} catch let e {
Logger.shared.log("NotificationSoundSelection", "copy file error \(e)")
TempBox.shared.dispose(tempFile)
EngineTempBox.shared.dispose(tempFile)
souceUrl.stopAccessingSecurityScopedResource()
return
}
guard let url = maybeUrl else {
Logger.shared.log("NotificationSoundSelection", "temp url is nil")
TempBox.shared.dispose(tempFile)
EngineTempBox.shared.dispose(tempFile)
souceUrl.stopAccessingSecurityScopedResource()
return
}
@@ -544,7 +543,7 @@ public func presentCustomNotificationSoundFilePicker(context: AccountContext, co
presentUndo(.info(title: presentationData.strings.Notifications_UploadError_TooLarge_Title, text: presentationData.strings.Notifications_UploadError_TooLarge_Text(dataSizeString(Int64(settings.maxSize), formatting: DataSizeStringFormatting(presentationData: presentationData))).string, timeout: nil))
souceUrl.stopAccessingSecurityScopedResource()
TempBox.shared.dispose(tempFile)
EngineTempBox.shared.dispose(tempFile)
return
}
@@ -572,7 +571,7 @@ public func presentCustomNotificationSoundFilePicker(context: AccountContext, co
Logger.shared.log("NotificationSoundSelection", "track is nil")
url.stopAccessingSecurityScopedResource()
TempBox.shared.dispose(tempFile)
EngineTempBox.shared.dispose(tempFile)
return
}
@@ -583,12 +582,12 @@ public func presentCustomNotificationSoundFilePicker(context: AccountContext, co
Logger.shared.log("NotificationSoundSelection", "duration is zero")
souceUrl.stopAccessingSecurityScopedResource()
TempBox.shared.dispose(tempFile)
EngineTempBox.shared.dispose(tempFile)
return
}
TempBox.shared.dispose(tempFile)
EngineTempBox.shared.dispose(tempFile)
Queue.mainQueue().async {
if duration > Double(settings.maxDuration) {