aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Hotline/Hotline/HotlineTrackerClient.swift4
-rw-r--r--Hotline/Models/Bookmark.swift4
-rw-r--r--Hotline/macOS/TrackerView.swift24
3 files changed, 28 insertions, 4 deletions
diff --git a/Hotline/Hotline/HotlineTrackerClient.swift b/Hotline/Hotline/HotlineTrackerClient.swift
index 36ed628..3c1ad85 100644
--- a/Hotline/Hotline/HotlineTrackerClient.swift
+++ b/Hotline/Hotline/HotlineTrackerClient.swift
@@ -166,14 +166,14 @@ class HotlineTrackerClient {
let ip_3 = bytes.consumeUInt8(),
let ip_4 = bytes.consumeUInt8(),
let port = bytes.consumeUInt16(),
- bytes.consume(2),
let userCount = bytes.consumeUInt16(),
+ bytes.consume(2),
let serverName = bytes.consumePString(),
let serverDescription = bytes.consumePString() else {
print("HotlineTrackerClient: Data isn't long enough for next server")
break
}
-
+
// Ignore servers that are just used as dividers in the tracker listing.
let validName = try? trackerSeparatorRegex.prefixMatch(in: serverName)
if validName == nil {
diff --git a/Hotline/Models/Bookmark.swift b/Hotline/Models/Bookmark.swift
index 115e5a9..733a6eb 100644
--- a/Hotline/Models/Bookmark.swift
+++ b/Hotline/Models/Bookmark.swift
@@ -31,6 +31,9 @@ final class Bookmark {
@Attribute(.ephemeral)
var serverDescription: String? = nil
+ @Attribute(.ephemeral)
+ var serverUserCount: Int? = nil
+
@Transient
var servers: [Bookmark] = []
@@ -94,6 +97,7 @@ final class Bookmark {
self.port = server.port
self.serverDescription = server.description
+ self.serverUserCount = server.users
}
init?(fileData: Data, name: String? = nil) {
diff --git a/Hotline/macOS/TrackerView.swift b/Hotline/macOS/TrackerView.swift
index ad0b08c..a52bccd 100644
--- a/Hotline/macOS/TrackerView.swift
+++ b/Hotline/macOS/TrackerView.swift
@@ -362,6 +362,8 @@ struct TrackerBookmarkSheet: View {
struct TrackerItemView: View {
let bookmark: Bookmark
+ @State private var onlineAnimationMaxState: Bool = true
+
var body: some View {
HStack(alignment: .center, spacing: 6) {
if bookmark.type == .tracker {
@@ -392,6 +394,7 @@ struct TrackerItemView: View {
.padding([.leading, .trailing], 2)
.controlSize(.small)
}
+ Spacer(minLength: 0)
case .server:
Image(systemName: "bookmark.fill")
.resizable()
@@ -406,6 +409,7 @@ struct TrackerItemView: View {
.scaledToFit()
.frame(width: 16, height: 16, alignment: .center)
Text(bookmark.name).lineLimit(1).truncationMode(.tail)
+ Spacer(minLength: 0)
case .temporary:
Spacer()
.frame(width: 14 + 8 + 16)
@@ -420,9 +424,25 @@ struct TrackerItemView: View {
.lineLimit(1)
.truncationMode(.tail)
}
+ Spacer(minLength: 0)
+ if let serverUserCount = bookmark.serverUserCount,
+ serverUserCount > 0 {
+ Text(String(serverUserCount))
+ .foregroundStyle(.secondary)
+ .lineLimit(1)
+
+ Circle()
+ .fill(.fileComplete)
+ .frame(width: 7, height: 7)
+ .opacity(onlineAnimationMaxState ? 1.0 : 0.2)
+ .onAppear {
+ withAnimation(.easeInOut(duration: 1.0).repeatForever()) {
+ onlineAnimationMaxState.toggle()
+ }
+ }
+ .padding(.trailing, 6)
+ }
}
-
- Spacer()
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.onChange(of: bookmark.expanded) {