✨ Render attachments of message on watchOS
This commit is contained in:
		| @@ -679,14 +679,10 @@ | |||||||
| 			inputFileListPaths = ( | 			inputFileListPaths = ( | ||||||
| 				"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist", | 				"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist", | ||||||
| 			); | 			); | ||||||
| 			inputPaths = ( |  | ||||||
| 			); |  | ||||||
| 			name = "[CP] Copy Pods Resources"; | 			name = "[CP] Copy Pods Resources"; | ||||||
| 			outputFileListPaths = ( | 			outputFileListPaths = ( | ||||||
| 				"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist", | 				"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist", | ||||||
| 			); | 			); | ||||||
| 			outputPaths = ( |  | ||||||
| 			); |  | ||||||
| 			runOnlyForDeploymentPostprocessing = 0; | 			runOnlyForDeploymentPostprocessing = 0; | ||||||
| 			shellPath = /bin/sh; | 			shellPath = /bin/sh; | ||||||
| 			shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n"; | 			shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n"; | ||||||
| @@ -744,14 +740,10 @@ | |||||||
| 			inputFileListPaths = ( | 			inputFileListPaths = ( | ||||||
| 				"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", | 				"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", | ||||||
| 			); | 			); | ||||||
| 			inputPaths = ( |  | ||||||
| 			); |  | ||||||
| 			name = "[CP] Embed Pods Frameworks"; | 			name = "[CP] Embed Pods Frameworks"; | ||||||
| 			outputFileListPaths = ( | 			outputFileListPaths = ( | ||||||
| 				"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", | 				"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", | ||||||
| 			); | 			); | ||||||
| 			outputPaths = ( |  | ||||||
| 			); |  | ||||||
| 			runOnlyForDeploymentPostprocessing = 0; | 			runOnlyForDeploymentPostprocessing = 0; | ||||||
| 			shellPath = /bin/sh; | 			shellPath = /bin/sh; | ||||||
| 			shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; | 			shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; | ||||||
| @@ -780,14 +772,10 @@ | |||||||
| 			inputFileListPaths = ( | 			inputFileListPaths = ( | ||||||
| 				"${PODS_ROOT}/Target Support Files/Pods-WatchRunner Watch App/Pods-WatchRunner Watch App-frameworks-${CONFIGURATION}-input-files.xcfilelist", | 				"${PODS_ROOT}/Target Support Files/Pods-WatchRunner Watch App/Pods-WatchRunner Watch App-frameworks-${CONFIGURATION}-input-files.xcfilelist", | ||||||
| 			); | 			); | ||||||
| 			inputPaths = ( |  | ||||||
| 			); |  | ||||||
| 			name = "[CP] Embed Pods Frameworks"; | 			name = "[CP] Embed Pods Frameworks"; | ||||||
| 			outputFileListPaths = ( | 			outputFileListPaths = ( | ||||||
| 				"${PODS_ROOT}/Target Support Files/Pods-WatchRunner Watch App/Pods-WatchRunner Watch App-frameworks-${CONFIGURATION}-output-files.xcfilelist", | 				"${PODS_ROOT}/Target Support Files/Pods-WatchRunner Watch App/Pods-WatchRunner Watch App-frameworks-${CONFIGURATION}-output-files.xcfilelist", | ||||||
| 			); | 			); | ||||||
| 			outputPaths = ( |  | ||||||
| 			); |  | ||||||
| 			runOnlyForDeploymentPostprocessing = 0; | 			runOnlyForDeploymentPostprocessing = 0; | ||||||
| 			shellPath = /bin/sh; | 			shellPath = /bin/sh; | ||||||
| 			shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-WatchRunner Watch App/Pods-WatchRunner Watch App-frameworks.sh\"\n"; | 			shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-WatchRunner Watch App/Pods-WatchRunner Watch App-frameworks.sh\"\n"; | ||||||
|   | |||||||
| @@ -260,6 +260,7 @@ struct ChatRoomView: View { | |||||||
|     @State private var isLoading = false |     @State private var isLoading = false | ||||||
|     @State private var error: Error? |     @State private var error: Error? | ||||||
|     @State private var wsState: WebSocketState = .disconnected // New state for WebSocket status |     @State private var wsState: WebSocketState = .disconnected // New state for WebSocket status | ||||||
|  |     @State private var hasLoadedMessages = false // Track if messages have been loaded | ||||||
|  |  | ||||||
|     @State private var cancellables = Set<AnyCancellable>() // For managing subscriptions |     @State private var cancellables = Set<AnyCancellable>() // For managing subscriptions | ||||||
|  |  | ||||||
| @@ -351,11 +352,17 @@ struct ChatRoomView: View { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     private func loadMessages() async { |     private func loadMessages() async { | ||||||
|  |         // Prevent reloading if already loaded | ||||||
|  |         guard !hasLoadedMessages else { return } | ||||||
|  |  | ||||||
|         guard let token = appState.token, let serverUrl = appState.serverUrl else { |         guard let token = appState.token, let serverUrl = appState.serverUrl else { | ||||||
|             isLoading = false |             isLoading = false | ||||||
|             return |             return | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         isLoading = true | ||||||
|  |         error = nil | ||||||
|  |  | ||||||
|         do { |         do { | ||||||
|             let messages = try await appState.networkService.fetchChatMessages( |             let messages = try await appState.networkService.fetchChatMessages( | ||||||
|                 chatRoomId: room.id, |                 chatRoomId: room.id, | ||||||
| @@ -364,6 +371,7 @@ struct ChatRoomView: View { | |||||||
|             ) |             ) | ||||||
|             // Sort with newest messages first (for flipped list, newest will appear at bottom) |             // Sort with newest messages first (for flipped list, newest will appear at bottom) | ||||||
|             self.messages = messages.sorted { $0.createdAt < $1.createdAt } |             self.messages = messages.sorted { $0.createdAt < $1.createdAt } | ||||||
|  |             hasLoadedMessages = true | ||||||
|         } catch { |         } catch { | ||||||
|             print("[watchOS] Error loading messages: \(error.localizedDescription)") |             print("[watchOS] Error loading messages: \(error.localizedDescription)") | ||||||
|             self.error = error |             self.error = error | ||||||
| @@ -487,12 +495,26 @@ struct ChatMessageItem: View { | |||||||
|                         .foregroundColor(.secondary) |                         .foregroundColor(.secondary) | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 if let content = message.content { |                 if let content = message.content, !content.isEmpty { | ||||||
|                     Text(content) |                     Text(content) | ||||||
|                         .font(.system(size: 14)) |                         .font(.system(size: 14)) | ||||||
|                         .lineLimit(nil) |                         .lineLimit(nil) | ||||||
|                         .fixedSize(horizontal: false, vertical: true) |                         .fixedSize(horizontal: false, vertical: true) | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|  |                 if !message.attachments.isEmpty { | ||||||
|  |                     AttachmentView(attachment: message.attachments[0]) | ||||||
|  |                     if message.attachments.count > 1 { | ||||||
|  |                         HStack(spacing: 8) { | ||||||
|  |                             Image(systemName: "paperclip.circle.fill") | ||||||
|  |                                 .frame(width: 12, height: 12) | ||||||
|  |                                 .foregroundStyle(.gray) | ||||||
|  |                             Text("\(message.attachments.count - 1)+ attachments") | ||||||
|  |                                 .font(.footnote) | ||||||
|  |                                 .foregroundStyle(.gray) | ||||||
|  |                         } | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         .padding(.vertical, 4) |         .padding(.vertical, 4) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user