diff options
| author | Dustin Mierau <dustin@mierau.me> | 2024-07-24 12:32:41 -0700 |
|---|---|---|
| committer | Dustin Mierau <dustin@mierau.me> | 2024-07-24 12:32:41 -0700 |
| commit | 8633db7e6ca9f38345d7be0ab90193d6325904bf (patch) | |
| tree | a950663e587c0bb0b051a61882ca9df6949a2446 /Hotline/Models/FilePreview.swift | |
| parent | 844317f8a3f5c7b11394653c8563c6e9c24d7e85 (diff) | |
First pass at uploads and a big refactoring of transfer clients. Also now showing download progress bar on file icon in dock (like Safari).
Diffstat (limited to 'Hotline/Models/FilePreview.swift')
| -rw-r--r-- | Hotline/Models/FilePreview.swift | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/Hotline/Models/FilePreview.swift b/Hotline/Models/FilePreview.swift index d558c4c..3960a0d 100644 --- a/Hotline/Models/FilePreview.swift +++ b/Hotline/Models/FilePreview.swift @@ -15,9 +15,9 @@ enum FilePreviewType: Equatable { } @Observable -final class FilePreview: HotlineFileClientDelegate { +final class FilePreview: HotlineFilePreviewClientDelegate { @ObservationIgnored let info: PreviewFileInfo - @ObservationIgnored var client: HotlineFileClient? = nil + @ObservationIgnored var client: HotlineFilePreviewClient? = nil var state: FilePreviewState = .unloaded var progress: Double = 0.0 @@ -49,20 +49,20 @@ final class FilePreview: HotlineFileClientDelegate { init(info: PreviewFileInfo) { self.info = info - self.client = HotlineFileClient(address: info.address, port: UInt16(info.port), reference: info.id, size: UInt32(info.size), type: .preview) + self.client = HotlineFilePreviewClient(address: info.address, port: UInt16(info.port), reference: info.id, size: UInt32(info.size)) self.client?.delegate = self } func download() { - self.client?.downloadToMemory() + self.client?.start() } func cancel() { - self.client?.cancel(deleteIncompleteFile: true) + self.client?.cancel() } - func hotlineFileStatusChanged(client: HotlineFileClient, reference: UInt32, status: HotlineFileClientStatus, timeRemaining: TimeInterval) { - print("FILE STATUS CHANGED", status) + func hotlineTransferStatusChanged(client: any HotlineTransferClient, reference: UInt32, status: HotlineTransferStatus, timeRemaining: TimeInterval) { + print("FilePreview: Download status changed:", status) switch status { case .unconnected: @@ -86,7 +86,7 @@ final class FilePreview: HotlineFileClientDelegate { } } - func hotlineFileDownloadedData(client: HotlineFileClient, reference: UInt32, data: Data) { + func hotlineFilePreviewComplete(client: HotlineFilePreviewClient, reference: UInt32, data: Data) { self.state = .loaded self.data = data |