Run SwiftFormat.

This commit is contained in:
Doug
2026-05-27 14:38:50 +01:00
committed by Doug
parent 5138e05e47
commit fa67713726
573 changed files with 2426 additions and 2426 deletions
@@ -38,7 +38,7 @@ class VoiceMessageCache: VoiceMessageCacheProtocol {
}
return .success(url)
}
func clearCache() {
if FileManager.default.fileExists(atPath: temporaryFilesFolderURL.path) {
do {
@@ -29,7 +29,7 @@ protocol VoiceMessageCacheProtocol {
/// - move: wheter to move or copy the source file
/// - Returns: the cached URL
func cache(mediaSource: MediaSourceProxy, using fileURL: URL, move: Bool) -> Result<URL, VoiceMessageCacheError>
/// Clears the cache
func clearCache()
}
@@ -36,7 +36,7 @@ class VoiceMessageMediaManager: VoiceMessageMediaManagerProtocol {
self.audioConverter = audioConverter
self.processingQueue = processingQueue
}
deinit {
voiceMessageCache.clearCache()
}
@@ -50,7 +50,7 @@ class VoiceMessageMediaManager: VoiceMessageMediaManagerProtocol {
if let fileURL = voiceMessageCache.fileURL(for: source) {
return fileURL
}
// Otherwise, load the file from source
guard case .success(let fileHandle) = await mediaProvider.loadFileFromSource(source, filename: body) else {
throw MediaProviderError.failedRetrievingFile
@@ -61,14 +61,14 @@ class VoiceMessageMediaManager: VoiceMessageMediaManagerProtocol {
if let fileURL = voiceMessageCache.fileURL(for: source) {
return fileURL
}
// Convert from ogg
guard let url = fileHandle.url else {
throw VoiceMessageMediaManagerError.missingURL
}
let convertedFileURL = URL.temporaryDirectory.appendingPathComponent(url.deletingPathExtension().lastPathComponent).appendingPathExtension(AudioConverterPreferredFileExtension.mpeg4aac.rawValue)
try audioConverter.convertToMPEG4AAC(sourceURL: url, destinationURL: convertedFileURL)
// Cache the file and return the url
let result = voiceMessageCache.cache(mediaSource: source, using: convertedFileURL, move: true)
switch result {
@@ -20,7 +20,7 @@ class VoiceMessageRecorder: VoiceMessageRecorderProtocol {
var actions: AnyPublisher<VoiceMessageRecorderAction, Never> {
actionsSubject.eraseToAnyPublisher()
}
private let mp4accMimeType = "audio/m4a"
var isRecording: Bool {
@@ -36,11 +36,11 @@ class VoiceMessageRecorder: VoiceMessageRecorderProtocol {
}
private var recordingCancelled = false
private(set) var previewAudioPlayerState: AudioPlayerState?
private(set) var previewAudioPlayer: AudioPlayerProtocol?
private var cancellables = Set<AnyCancellable>()
init(audioRecorder: AudioRecorderProtocol = AudioRecorder(),
mediaPlayerProvider: MediaPlayerProviderProtocol,
voiceMessageCache: VoiceMessageCacheProtocol = VoiceMessageCache()) {
@@ -86,7 +86,7 @@ class VoiceMessageRecorder: VoiceMessageRecorderProtocol {
previewAudioPlayer?.reset()
previewAudioPlayerState = nil
}
// MARK: - Preview
func startPlayback() async -> Result<Void, VoiceMessageRecorderError> {
@@ -158,13 +158,13 @@ class VoiceMessageRecorder: VoiceMessageRecorderProtocol {
// delete the temporary file
try? FileManager.default.removeItem(at: oggFile)
}
do {
try audioConverter.convertToOpusOgg(sourceURL: url, destinationURL: oggFile)
} catch {
return .failure(.failedSendingVoiceMessage)
}
// send it
let size: UInt64
do {
@@ -189,7 +189,7 @@ class VoiceMessageRecorder: VoiceMessageRecorderProtocol {
return .success(())
}
// MARK: - Private
private func addObservers() {
@@ -237,10 +237,10 @@ class VoiceMessageRecorder: VoiceMessageRecorderProtocol {
guard audioRecorder.audioFileURL != nil, audioRecorder.currentTime > 0 else {
return .failure(.previewNotAvailable)
}
// Build the preview audio player state
previewAudioPlayerState = await AudioPlayerState(id: .recorderPreview, title: L10n.commonVoiceMessage, duration: recordingDuration, waveform: EstimatedWaveform(data: []))
// Build the preview audio player
let audioPlayer = await mediaPlayerProvider.player
previewAudioPlayer = audioPlayer
@@ -27,9 +27,9 @@ protocol VoiceMessageRecorderProtocol {
var previewAudioPlayerState: AudioPlayerState? { get }
var isRecording: Bool { get }
var recordingURL: URL? { get }
var actions: AnyPublisher<VoiceMessageRecorderAction, Never> { get }
func startRecording() async
func stopRecording() async
func cancelRecording() async