From cea0579bce549c2c5dd8726ebf2b36dc1e57aaec Mon Sep 17 00:00:00 2001 From: jack Date: Thu, 24 Jul 2025 13:47:44 +0200 Subject: [PATCH] Fix build error: move PeerDisplayData struct outside ViewBuilder - Move struct declaration to top level to avoid ViewBuilder error - Struct declarations cannot be inside ViewBuilder closures --- bitchat/Views/ContentView.swift | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/bitchat/Views/ContentView.swift b/bitchat/Views/ContentView.swift index 828bdd10..7892e29d 100644 --- a/bitchat/Views/ContentView.swift +++ b/bitchat/Views/ContentView.swift @@ -8,6 +8,17 @@ import SwiftUI +// Pre-computed peer data for performance +struct PeerDisplayData: Identifiable { + let id: String + let displayName: String + let rssi: Int? + let isFavorite: Bool + let isMe: Bool + let hasUnreadMessages: Bool + let encryptionStatus: EncryptionStatus +} + // Lazy loading wrapper for link previews struct LazyLinkPreviewView: View { let url: URL @@ -577,16 +588,6 @@ struct ContentView: View { let peersToShow: [String] = viewModel.connectedPeers // Pre-compute peer data outside ForEach to reduce overhead - struct PeerDisplayData: Identifiable { - let id: String - let displayName: String - let rssi: Int? - let isFavorite: Bool - let isMe: Bool - let hasUnreadMessages: Bool - let encryptionStatus: EncryptionStatus - } - let peerData = peersToShow.map { peerID in PeerDisplayData( id: peerID,