diff options
| author | Dustin Mierau <dustin@mierau.me> | 2023-12-19 20:38:13 -0800 |
|---|---|---|
| committer | Dustin Mierau <dustin@mierau.me> | 2023-12-19 20:38:13 -0800 |
| commit | 4fd69c02a3e7b581bb9229865336c315153f3b18 (patch) | |
| tree | e6e11d872424196f2b4033077902126ad5556e40 /Hotline/Models/Server.swift | |
| parent | 5e87b5927cd931d46fb5f72fb035480a95969a9f (diff) | |
Beginnings of a UI for macOS as well as some visual changes to iOS client. :)
Diffstat (limited to 'Hotline/Models/Server.swift')
| -rw-r--r-- | Hotline/Models/Server.swift | 13 |
1 files changed, 7 insertions, 6 deletions
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 } } |