From f20848740b2eb0f35373218f6a4fe96f974b05d3 Mon Sep 17 00:00:00 2001 From: jack <212554440+jackjackbits@users.noreply.github.com> Date: Sat, 28 Nov 2026 13:39:43 -1000 Subject: [PATCH] Remove per-row lock and verified badges in private chats, show lock in group header (#1944) * Remove per-row lock icon in private chats and show lock in group header * Remove per-row verification badge from private chat rows --------- Co-authored-by: jack --- bitchat/App/ConversationUIModel.swift | 16 +--- bitchat/ViewModels/ChatMessageFormatter.swift | 5 +- .../Views/Components/DeliveryStatusView.swift | 20 +---- .../Views/Components/TextMessageView.swift | 11 +-- bitchat/Views/ContentSheetViews.swift | 12 +++ bitchat/Views/Media/MediaMessageView.swift | 81 +++++++++---------- .../ChatViewModelExtensionsTests.swift | 12 +-- bitchatTests/ConversationUIModelTests.swift | 14 +++- 8 files changed, 68 insertions(+), 103 deletions(-) diff --git a/bitchat/App/ConversationUIModel.swift b/bitchat/App/ConversationUIModel.swift index b929f222..6efa7c10 100644 --- a/bitchat/App/ConversationUIModel.swift +++ b/bitchat/App/ConversationUIModel.swift @@ -194,18 +194,6 @@ final class ConversationUIModel: ObservableObject { return peerID } - /// Whether a private-message row should show the filled verification seal - /// next to the sender name (#1439). Scoped to DMs only — public timelines - /// have different trust semantics and stay undressed. - func showsVerifiedSeal(for message: BitchatMessage) -> Bool { - guard message.isPrivate, - message.sender != "system", - !isSentByCurrentUser(message), - let peerID = message.senderPeerID else { return false } - guard let fingerprint = chatViewModel.getFingerprint(for: peerID) else { return false } - return chatViewModel.peerIdentityStore.isVerified(fingerprint) - } - func senderDisplayName(for peerID: PeerID, fallbackMessages: [BitchatMessage]) -> String? { if peerID.isGeoDM || peerID.isGeoChat { return chatViewModel.geohashDisplayName(for: peerID) @@ -342,8 +330,8 @@ final class ConversationUIModel: ObservableObject { } .store(in: &cancellables) - // Verify/unverify while a DM is open must repaint existing rows — - // showsVerifiedSeal is computed per render, so forward the store change. + // Verify/unverify while a public timeline is open must repaint + // existing rows so the inline verified checkmark updates immediately. chatViewModel.peerIdentityStore.$verifiedFingerprints .removeDuplicates() .dropFirst() diff --git a/bitchat/ViewModels/ChatMessageFormatter.swift b/bitchat/ViewModels/ChatMessageFormatter.swift index b273a615..0ec7b7be 100644 --- a/bitchat/ViewModels/ChatMessageFormatter.swift +++ b/bitchat/ViewModels/ChatMessageFormatter.swift @@ -90,9 +90,8 @@ final class ChatMessageFormatter { suffixStyle.foregroundColor = baseColor.opacity(0.6) result.append(AttributedString(suffix).mergingAttributes(suffixStyle)) } - // Private rows render a filled SF Symbol seal beside the lock - // (TextMessageView / MediaMessageView); skip the in-string ✓ there - // so verified DMs don't show two markers. + // Verification for 1:1 DMs lives in the chat header rather than + // repeating a seal on every private message row. if isVerifiedSender, !message.isPrivate { appendVerifiedSeal(to: &result, baseColor: baseColor, design: design) } diff --git a/bitchat/Views/Components/DeliveryStatusView.swift b/bitchat/Views/Components/DeliveryStatusView.swift index f4ca24c1..f5879513 100644 --- a/bitchat/Views/Components/DeliveryStatusView.swift +++ b/bitchat/Views/Components/DeliveryStatusView.swift @@ -141,29 +141,11 @@ struct DeliveryStatusView: View { } } -/// Leading inline badges shared by text and media message rows. +/// Leading inline badge for message rows that arrived across a mesh bridge. struct MessageLeadingBadges: View { - let isPrivate: Bool - let showsVerifiedSeal: Bool var isBridged: Bool = false var body: some View { - if isPrivate { - Image(systemName: "lock.fill") - .font(.bitchatSystem(size: 8)) - .foregroundColor(Color.orange.opacity(0.75)) - .padding(.trailing, 4) - .accessibilityHidden(true) - } - if showsVerifiedSeal { - Image(systemName: "checkmark.seal.fill") - .font(.bitchatSystem(size: 8)) - .foregroundColor(Color.green.opacity(0.85)) - .padding(.trailing, 4) - .accessibilityLabel( - String(localized: "content.accessibility.verified_sender", defaultValue: "Verified sender", comment: "Accessibility label for the seal next to a verified peer's name on a private message") - ) - } if isBridged { Image(systemName: "network") .font(.bitchatSystem(size: 8)) diff --git a/bitchat/Views/Components/TextMessageView.swift b/bitchat/Views/Components/TextMessageView.swift index e289808a..321e6bc3 100644 --- a/bitchat/Views/Components/TextMessageView.swift +++ b/bitchat/Views/Components/TextMessageView.swift @@ -95,16 +95,11 @@ struct TextMessageView: View, Equatable { .buttonStyle(.plain) .padding(.bottom, 4) } - // Baseline alignment keeps the lock and delivery glyphs on the - // first text line; a fixed top padding left the lock's solid body - // hanging below the line's visual center. + // Baseline alignment keeps leading badges and delivery glyphs on + // the first text line rather than hanging below its visual center. HStack(alignment: .firstTextBaseline, spacing: 0) { let isExpanded = expandedMessageIDs.contains(message.id) - MessageLeadingBadges( - isPrivate: message.isPrivate, - showsVerifiedSeal: conversationUIModel.showsVerifiedSeal(for: message), - isBridged: message.isBridged - ) + MessageLeadingBadges(isBridged: message.isBridged) Text(conversationUIModel.formatMessage(message, colorScheme: colorScheme, theme: theme)) .fixedSize(horizontal: false, vertical: true) .lineLimit(scan.isLongForDisplay && !isExpanded ? TransportConfig.uiLongMessageLineLimit : nil) diff --git a/bitchat/Views/ContentSheetViews.swift b/bitchat/Views/ContentSheetViews.swift index 80547da3..a343106c 100644 --- a/bitchat/Views/ContentSheetViews.swift +++ b/bitchat/Views/ContentSheetViews.swift @@ -847,6 +847,18 @@ private struct ContentPrivateHeaderInfoButton: View { encryptionStatus.accessibilityDescription ) ) + } else if headerState.isGroupConversation { + Image(systemName: "lock.fill") + .font(.system(size: 13, weight: .medium)) + .offset(y: -0.5) + .foregroundColor(palette.secondary) + .accessibilityLabel( + String( + format: String(localized: "content.accessibility.encryption_status", comment: "Accessibility label announcing encryption status"), + locale: .current, + EncryptionStatus.noiseSecured.accessibilityDescription + ) + ) } } diff --git a/bitchat/Views/Media/MediaMessageView.swift b/bitchat/Views/Media/MediaMessageView.swift index 063b935a..06803cba 100644 --- a/bitchat/Views/Media/MediaMessageView.swift +++ b/bitchat/Views/Media/MediaMessageView.swift @@ -37,54 +37,45 @@ struct MediaMessageView: View { let cancelAction: (() -> Void)? = state.canCancel ? { conversationUIModel.cancelMediaSend(messageID: message.id) } : nil let showsDeliveryStatus = conversationUIModel.showsDeliveryStatus(for: message, status: deliveryStatus) - // Baseline alignment (via the header text inside the VStack) keeps the - // lock on the header line; a fixed top padding left its solid body - // hanging below the line's visual center. - HStack(alignment: .firstTextBaseline, spacing: 0) { - MessageLeadingBadges( - isPrivate: message.isPrivate, - showsVerifiedSeal: conversationUIModel.showsVerifiedSeal(for: message) - ) - VStack(alignment: .leading, spacing: 2) { - HStack(alignment: .center, spacing: 4) { - Text(conversationUIModel.formatMessageHeader(message, colorScheme: colorScheme, theme: theme)) - .fixedSize(horizontal: false, vertical: true) - .frame(maxWidth: .infinity, alignment: .leading) - if showsDeliveryStatus { - MessageDeliveryStatusButton(status: deliveryStatus, showDetail: $showDeliveryDetail) - } - } - + VStack(alignment: .leading, spacing: 2) { + HStack(alignment: .center, spacing: 4) { + Text(conversationUIModel.formatMessageHeader(message, colorScheme: colorScheme, theme: theme)) + .fixedSize(horizontal: false, vertical: true) + .frame(maxWidth: .infinity, alignment: .leading) if showsDeliveryStatus { - MessageDeliveryDetailCaption(status: deliveryStatus, showDetail: showDeliveryDetail) + MessageDeliveryStatusButton(status: deliveryStatus, showDetail: $showDeliveryDetail) } + } - Group { - switch media { - case .voice(let url): - VoiceNoteView( - url: url, - isSending: state.isSending, - sendProgress: state.progress, - isLive: conversationUIModel.isLiveVoiceMessage(message), - onCancel: cancelAction - ) - case .image(let url): - BlockRevealImageView( - url: url, - revealProgress: state.progress, - isSending: state.isSending, - onCancel: cancelAction, - initiallyBlurred: !isFromMe, - onOpen: { - if !state.isSending { - imagePreviewURL = url - } - }, - onDelete: !isFromMe ? { conversationUIModel.deleteMediaMessage(messageID: message.id) } : nil - ) - .frame(maxWidth: 280) - } + if showsDeliveryStatus { + MessageDeliveryDetailCaption(status: deliveryStatus, showDetail: showDeliveryDetail) + } + + Group { + switch media { + case .voice(let url): + VoiceNoteView( + url: url, + isSending: state.isSending, + sendProgress: state.progress, + isLive: conversationUIModel.isLiveVoiceMessage(message), + onCancel: cancelAction + ) + case .image(let url): + BlockRevealImageView( + url: url, + revealProgress: state.progress, + isSending: state.isSending, + onCancel: cancelAction, + initiallyBlurred: !isFromMe, + onOpen: { + if !state.isSending { + imagePreviewURL = url + } + }, + onDelete: !isFromMe ? { conversationUIModel.deleteMediaMessage(messageID: message.id) } : nil + ) + .frame(maxWidth: 280) } } } diff --git a/bitchatTests/ChatViewModelExtensionsTests.swift b/bitchatTests/ChatViewModelExtensionsTests.swift index de0afcac..3deba5c9 100644 --- a/bitchatTests/ChatViewModelExtensionsTests.swift +++ b/bitchatTests/ChatViewModelExtensionsTests.swift @@ -264,16 +264,8 @@ struct ChatViewModelPrivateChatExtensionTests { #expect(meshRowSender == shortPeerID) viewModel.peerIdentityStore.setVerified("fp-1", verified: true) - let privateModel = PrivateConversationModel( - chatViewModel: viewModel, conversations: viewModel.conversations, - locationChannelsModel: LocationChannelsModel(manager: viewModel.locationManager) - ) - let uiModel = ConversationUIModel( - chatViewModel: viewModel, privateConversationModel: privateModel, - conversations: viewModel.conversations - ) - let meshRow = joined.first { $0.id == "mesh-1" } - #expect(meshRow.map { uiModel.showsVerifiedSeal(for: $0) } == true) + #expect(meshRowSender.flatMap { viewModel.getFingerprint(for: $0) } == "fp-1") + #expect(meshRowSender.flatMap { viewModel.getFingerprint(for: $0) }.map { viewModel.peerIdentityStore.isVerified($0) } == true) // Blocking from the moved row reaches the peer's identity. if let meshRowSender { diff --git a/bitchatTests/ConversationUIModelTests.swift b/bitchatTests/ConversationUIModelTests.swift index 36e58c01..19672f18 100644 --- a/bitchatTests/ConversationUIModelTests.swift +++ b/bitchatTests/ConversationUIModelTests.swift @@ -271,15 +271,21 @@ struct ConversationUIModelTests { } @Test @MainActor - func verifiedNamesakeKeepsTheSealOnTheirDMs() { + func verifiedNamesakeGetsSealOnPublicMessagesButNotPrivateRows() { let (viewModel, transport) = makeChatViewModel(nickname: "alice") let uiModel = makeUIModel(for: viewModel) transport.peerFingerprints[Self.peerID] = "namesake-fingerprint" viewModel.peerIdentityStore.setVerified("namesake-fingerprint", verified: true) - // The seal is what tells a verified "alice" from an impersonator. - #expect(uiModel.showsVerifiedSeal(for: row("alice", Self.peerID, isPrivate: true))) - #expect(!uiModel.showsVerifiedSeal(for: row("alice", Self.myPeerID, isPrivate: true))) + // Public mesh rows mark a verified namesake with ✓ so they stay + // distinct from an impersonator; private rows omit per-row badges + // since verification is shown in the chat header. + let publicFromNamesake = String(uiModel.formatMessage(row("alice", Self.peerID, isPrivate: false), colorScheme: .dark, theme: .matrix).characters) + let publicFromMe = String(uiModel.formatMessage(row("alice", Self.myPeerID, isPrivate: false), colorScheme: .dark, theme: .matrix).characters) + let privateFromNamesake = String(uiModel.formatMessage(row("alice", Self.peerID, isPrivate: true), colorScheme: .dark, theme: .matrix).characters) + #expect(publicFromNamesake.contains("✓")) + #expect(!publicFromMe.contains("✓")) + #expect(!privateFromNamesake.contains("✓")) } @Test @MainActor