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 <jackjackbits@users.noreply.github.com>
This commit is contained in:
jackandjack authored and GitHub committed 2026-11-28 13:39:43 -10:00
1 parent 1240953c26
commit f20848740b
8 files changed
+68 -103

No files matched your search

+2 -14
View File
@@ -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()
@@ -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)
}
@@ -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))
@@ -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)
+12
View File
@@ -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
)
)
}
}
+36 -45
View File
@@ -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)
}
}
}
@@ -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 {
+10 -4
View File
@@ -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