From 2f8f71d0410f59d5d303a4c221a628630168bfe2 Mon Sep 17 00:00:00 2001 From: Dustin Mierau Date: Fri, 5 Jan 2024 19:46:13 -0800 Subject: Add image preview to Files so you don't have to download images to view them, works with animated GIFs too. Added cmd-R shortcut for Servers window. More work on login view. --- Hotline/Models/Hotline.swift | 98 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 81 insertions(+), 17 deletions(-) (limited to 'Hotline/Models/Hotline.swift') diff --git a/Hotline/Models/Hotline.swift b/Hotline/Models/Hotline.swift index 3e3bf26..e88c267 100644 --- a/Hotline/Models/Hotline.swift +++ b/Hotline/Models/Hotline.swift @@ -1,6 +1,7 @@ import SwiftUI -@Observable final class Hotline: HotlineClientDelegate, HotlineFileClientDelegate { +@Observable +final class Hotline: HotlineClientDelegate, HotlineFileClientDelegate { let trackerClient: HotlineTrackerClient let client: HotlineClient @@ -239,13 +240,15 @@ import SwiftUI self.trackerClient.disconnect() } - @MainActor func login(server: Server, login: String, password: String, username: String, iconID: Int, callback: ((Bool) -> Void)? = nil) { + @MainActor func login(server: Server, username: String, iconID: Int, callback: ((Bool) -> Void)? = nil) { self.server = server self.serverName = server.name self.username = username self.iconID = iconID - self.client.login(server.address, port: UInt16(server.port), login: login, password: password, username: username, iconID: UInt16(iconID)) { [weak self] err, serverName, serverVersion in + print("CLIENT LOGIN: '\(server.login)' '\(server.password == nil)'") + + self.client.login(server.address, port: UInt16(server.port), login: server.login, password: server.password, username: username, iconID: UInt16(iconID)) { [weak self] err, serverName, serverVersion in self?.serverVersion = serverVersion if serverName != nil { self?.serverName = serverName @@ -519,16 +522,21 @@ import SwiftUI }) } - @MainActor func previewFile(_ fileName: String, path: [String], addTransfer: Bool = false, complete callback: ((TransferInfo, Data) -> Void)? = nil) { + @MainActor func previewFile(_ fileName: String, path: [String], complete callback: ((PreviewFileInfo?) -> Void)? = nil) { var fullPath: [String] = [] if path.count > 1 { fullPath = Array(path[0.. Void)? = nil) { +// var fullPath: [String] = [] +// if path.count > 1 { +// fullPath = Array(path[0..