From 4fd69c02a3e7b581bb9229865336c315153f3b18 Mon Sep 17 00:00:00 2001 From: Dustin Mierau Date: Tue, 19 Dec 2023 20:38:13 -0800 Subject: Beginnings of a UI for macOS as well as some visual changes to iOS client. :) --- Hotline/Models/Server.swift | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'Hotline/Models/Server.swift') diff --git a/Hotline/Models/Server.swift b/Hotline/Models/Server.swift index 8b5ea56..495d236 100644 --- a/Hotline/Models/Server.swift +++ b/Hotline/Models/Server.swift @@ -1,9 +1,9 @@ import SwiftUI -@Observable final class Server: Identifiable, Equatable { +@Observable final class Server: Identifiable, Equatable, Hashable, Codable { static let defaultPort: Int = 5500 - let id: UUID = UUID() + let id: UUID let name: String? let description: String? let users: Int @@ -11,6 +11,7 @@ import SwiftUI let port: Int init(name: String?, description: String?, address: String, port: Int, users: Int = 0) { + self.id = UUID() self.name = name self.description = description self.address = address @@ -18,11 +19,11 @@ import SwiftUI self.users = users } - static func == (lhs: Server, rhs: Server) -> Bool { - return lhs.id == rhs.id + func hash(into hasher: inout Hasher) { + hasher.combine(self.id) } - static func == (lhs: HotlineServer, rhs: Server) -> Bool { - return lhs.name == rhs.name && lhs.address == rhs.address && lhs.port == rhs.port + static func == (lhs: Server, rhs: Server) -> Bool { + return lhs.id == rhs.id } } -- cgit