aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Hotline.xcodeproj/project.pbxproj4
-rw-r--r--Hotline/Hotline/HotlineClient.swift4
-rw-r--r--Hotline/Hotline/HotlineProtocol.swift9
-rw-r--r--Hotline/State/HotlineState.swift2
-rw-r--r--Hotline/macOS/MessageView.swift50
-rw-r--r--Hotline/macOS/UserInfo.swift25
6 files changed, 51 insertions, 43 deletions
diff --git a/Hotline.xcodeproj/project.pbxproj b/Hotline.xcodeproj/project.pbxproj
index 15453da..2b3c8e9 100644
--- a/Hotline.xcodeproj/project.pbxproj
+++ b/Hotline.xcodeproj/project.pbxproj
@@ -99,6 +99,7 @@
DABE8C002B55E69800884D28 /* server-message.aiff in Resources */ = {isa = PBXBuildFile; fileRef = DABE8BFF2B55E69800884D28 /* server-message.aiff */; };
DABE8C022B55E69D00884D28 /* new-news.aiff in Resources */ = {isa = PBXBuildFile; fileRef = DABE8C012B55E69D00884D28 /* new-news.aiff */; };
DABE8C042B57940B00884D28 /* DAKeychain.swift in Sources */ = {isa = PBXBuildFile; fileRef = DABE8C032B57940A00884D28 /* DAKeychain.swift */; };
+ DAC0E4232EC78E1100E999DB /* UserInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAC0E4222EC78E1100E999DB /* UserInfo.swift */; };
DAC3D9832BC33FD000A727C9 /* AppState.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAC3D9822BC33FD000A727C9 /* AppState.swift */; };
DAC6B2E02EAC6236004E2CBA /* ChatStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAC6B2DE2EAC6236004E2CBA /* ChatStore.swift */; };
DAC6B2E22EAEE9FE004E2CBA /* NetSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAC6B2E12EAEE9EF004E2CBA /* NetSocket.swift */; };
@@ -214,6 +215,7 @@
DABE8BFF2B55E69800884D28 /* server-message.aiff */ = {isa = PBXFileReference; lastKnownFileType = audio.aiff; path = "server-message.aiff"; sourceTree = "<group>"; };
DABE8C012B55E69D00884D28 /* new-news.aiff */ = {isa = PBXFileReference; lastKnownFileType = audio.aiff; path = "new-news.aiff"; sourceTree = "<group>"; };
DABE8C032B57940A00884D28 /* DAKeychain.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DAKeychain.swift; sourceTree = "<group>"; };
+ DAC0E4222EC78E1100E999DB /* UserInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserInfo.swift; sourceTree = "<group>"; };
DAC3D9822BC33FD000A727C9 /* AppState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppState.swift; sourceTree = "<group>"; };
DAC6B2DE2EAC6236004E2CBA /* ChatStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatStore.swift; sourceTree = "<group>"; };
DAC6B2E12EAEE9EF004E2CBA /* NetSocket.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetSocket.swift; sourceTree = "<group>"; };
@@ -532,6 +534,7 @@
DAE734F72B2E4126000C56F6 /* macOS */ = {
isa = PBXGroup;
children = (
+ DAC0E4222EC78E1100E999DB /* UserInfo.swift */,
DA55AC762BE589F700034857 /* AboutView.swift */,
DACCE5E22EABE86A008CDD92 /* AppUpdateView.swift */,
DAE136B92B9D1147007D8307 /* HotlinePanelView.swift */,
@@ -738,6 +741,7 @@
DA5268B32EB6806E00DCB941 /* HotlineFileDownloadClient.swift in Sources */,
DACCE5E32EABE86A008CDD92 /* AppUpdateView.swift in Sources */,
DAC6B2E02EAC6236004E2CBA /* ChatStore.swift in Sources */,
+ DAC0E4232EC78E1100E999DB /* UserInfo.swift in Sources */,
DA32CD492B2931640053B98B /* User.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
diff --git a/Hotline/Hotline/HotlineClient.swift b/Hotline/Hotline/HotlineClient.swift
index 1394057..1440b71 100644
--- a/Hotline/Hotline/HotlineClient.swift
+++ b/Hotline/Hotline/HotlineClient.swift
@@ -552,7 +552,7 @@ public actor HotlineClient {
///
/// - Parameters:
/// - userID: Target user ID
- public func getClientInfoText(for userID: UInt16) async throws -> (username: String, info: String)? {
+ public func getClientInfoText(for userID: UInt16) async throws -> HotlineUserClientInfo? {
var transaction = HotlineTransaction(id: self.generateTransactionID(), type: .getClientInfoText)
transaction.setFieldUInt16(type: .userID, val: userID)
@@ -560,7 +560,7 @@ public actor HotlineClient {
if let username = reply.getField(type: .userName)?.getString(),
let info = reply.getField(type: .data)?.getString() {
- return (username: username, info: info)
+ return HotlineUserClientInfo(username: username, details: info)
}
return nil
diff --git a/Hotline/Hotline/HotlineProtocol.swift b/Hotline/Hotline/HotlineProtocol.swift
index 4857d87..92fdfd2 100644
--- a/Hotline/Hotline/HotlineProtocol.swift
+++ b/Hotline/Hotline/HotlineProtocol.swift
@@ -516,6 +516,15 @@ public class HotlineFile: Identifiable, Hashable {
}
}
+public struct HotlineUserClientInfo: Identifiable {
+ public var username: String
+ public var details: String
+
+ public var id: String {
+ self.username
+ }
+}
+
public struct HotlineUser: Identifiable, Hashable, Sendable {
public let id: UInt16
public let iconID: UInt16
diff --git a/Hotline/State/HotlineState.swift b/Hotline/State/HotlineState.swift
index 318a468..e78a780 100644
--- a/Hotline/State/HotlineState.swift
+++ b/Hotline/State/HotlineState.swift
@@ -798,7 +798,7 @@ class HotlineState: Equatable {
self.users = hotlineUsers.map { User(hotlineUser: $0) }
}
- func getClientInfoText(id userID: UInt16) async throws -> (username: String, info: String)? {
+ func getClientInfoText(id userID: UInt16) async throws -> HotlineUserClientInfo? {
guard let client = self.client else {
throw HotlineClientError.notConnected
}
diff --git a/Hotline/macOS/MessageView.swift b/Hotline/macOS/MessageView.swift
index 861a14a..6690a88 100644
--- a/Hotline/macOS/MessageView.swift
+++ b/Hotline/macOS/MessageView.swift
@@ -1,37 +1,5 @@
import SwiftUI
-struct UserInfo: Identifiable {
- let username: String
- let data: String
-
- var id: String {
- self.username
- }
-}
-
-struct UserInfoView: View {
- @Environment(\.dismiss) private var dismiss
-
- let info: UserInfo
-
- var body: some View {
- ScrollView(.vertical) {
- Text(self.info.data)
- .fontDesign(.monospaced)
- .textSelection(.enabled)
- .padding()
- }
- .frame(width: 300, height: 400)
- .toolbar {
- if #available(macOS 26.0, *) {
- Button(role: .close) {
- self.dismiss()
- }
- }
- }
- }
-}
-
struct MessageView: View {
@Environment(HotlineState.self) private var model: HotlineState
@Environment(\.colorScheme) private var colorScheme
@@ -39,7 +7,7 @@ struct MessageView: View {
@State private var input: String = ""
@State private var scrollPos: Int?
@State private var contentHeight: CGFloat = 0
- @State private var userInfo: UserInfo?
+ @State private var userInfo: HotlineUserClientInfo?
@Namespace private var bottomID
@FocusState private var focusedField: FocusedField?
@@ -60,11 +28,13 @@ struct MessageView: View {
}
.background(Color(nsColor: .textBackgroundColor))
.toolbar {
- ToolbarItem {
- Button {
- self.getUserInfo()
- } label: {
- Image(systemName: "info.circle")
+ if self.model.access?.contains(.canGetClientInfo) == true {
+ ToolbarItem {
+ Button {
+ self.getUserInfo()
+ } label: {
+ Image(systemName: "info.circle")
+ }
}
}
}
@@ -75,8 +45,8 @@ struct MessageView: View {
private func getUserInfo() {
Task {
- if let (username, info) = try await self.model.getClientInfoText(id: self.userID) {
- self.userInfo = UserInfo(username: username, data: info)
+ if let info = try await self.model.getClientInfoText(id: self.userID) {
+ self.userInfo = info
}
}
}
diff --git a/Hotline/macOS/UserInfo.swift b/Hotline/macOS/UserInfo.swift
new file mode 100644
index 0000000..328fc02
--- /dev/null
+++ b/Hotline/macOS/UserInfo.swift
@@ -0,0 +1,25 @@
+import SwiftUI
+
+struct UserInfoView: View {
+ @Environment(\.dismiss) private var dismiss
+
+ let info: HotlineUserClientInfo
+
+ var body: some View {
+ ScrollView(.vertical) {
+ Text(self.info.details)
+ .fontDesign(.monospaced)
+ .textSelection(.enabled)
+ .frame(maxWidth: .infinity, alignment: .topLeading)
+ .padding()
+ }
+ .frame(width: 350, height: 400)
+ .toolbar {
+ ToolbarItem(placement: .confirmationAction) {
+ Button("OK") {
+ self.dismiss()
+ }
+ }
+ }
+ }
+}