aboutsummaryrefslogtreecommitdiff
path: root/Hotline/Models/Server.swift
diff options
context:
space:
mode:
authorDustin Mierau <dustin@mierau.me>2024-01-01 11:35:49 -0800
committerDustin Mierau <dustin@mierau.me>2024-01-01 11:35:49 -0800
commit5d2aadbc834393b532d043d6298d6a23b80c2a5c (patch)
treedcf139b67179d5bc3ad3ed69e949a1e7c1d18177 /Hotline/Models/Server.swift
parenta4cbaea0b12b7dd42133b4bd14f1371f1000fcc0 (diff)
File downloads now working in macOS client.1.0beta4
Diffstat (limited to 'Hotline/Models/Server.swift')
-rw-r--r--Hotline/Models/Server.swift32
1 files changed, 19 insertions, 13 deletions
diff --git a/Hotline/Models/Server.swift b/Hotline/Models/Server.swift
index b39f1c4..2275036 100644
--- a/Hotline/Models/Server.swift
+++ b/Hotline/Models/Server.swift
@@ -1,29 +1,35 @@
import SwiftUI
-struct Server: Identifiable, Equatable, Hashable, Codable {
+struct Server: Codable {
static let defaultPort: Int = 5500
- let id: UUID
- let name: String?
- let description: String?
- let users: Int
- let address: String
- let port: Int
+ var name: String?
+ var description: String?
+ var users: Int
+ var address: String
+ var 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.lowercased()
self.port = port
self.users = users
}
-
- func hash(into hasher: inout Hasher) {
- hasher.combine(self.id)
- }
-
+}
+
+extension Server: Identifiable {
+ var id: String { "\(address):\(port)" }
+}
+
+extension Server: Equatable {
static func == (lhs: Server, rhs: Server) -> Bool {
return (lhs.address == rhs.address) && (lhs.port == rhs.port)
}
}
+
+extension Server: Hashable {
+ func hash(into hasher: inout Hasher) {
+ hasher.combine(self.id)
+ }
+}