Skip to content

Commit 4337333

Browse files
committed
address feedback
1 parent a38f794 commit 4337333

2 files changed

Lines changed: 35 additions & 10 deletions

File tree

Convos/Contacts/Profile+ContactOverlay.swift

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,43 @@ extension Contact {
1111
/// the message bubble renders - keeps those rows in sync with the bubble after
1212
/// a participant changes their photo.
1313
///
14-
/// Name, emoji, and other identity fields are deliberately left as the stored
15-
/// contact's, so contact-authoritative name resolution (and any future local
16-
/// nickname) is unaffected - only the avatar image is freshened.
14+
/// The avatar image (url + its crypto) is taken wholesale from the member
15+
/// profile - never field-by-field merged with the stored contact - so a
16+
/// change-photo shows the new image, and a partial/malformed member avatar
17+
/// renders the same monogram as the bubble (copying the fields verbatim keeps
18+
/// `Profile.isEncryptedImage`'s all-or-nothing crypto check identical).
19+
///
20+
/// The display name is deliberately left as the stored contact's, so
21+
/// contact-authoritative name resolution (and any future local nickname) is
22+
/// unaffected - only the avatar is freshened.
23+
///
24+
/// Known limitation (deferred): this does not handle a member who *clears*
25+
/// their avatar (nil url) or switches to emoji-only. The caller renders via
26+
/// `Profile.overlaying(contact:)`, which falls back to the frozen per-message
27+
/// snapshot's avatar/metadata when the override carries no avatar url, so the
28+
/// row would resurface the stale snapshot photo/emoji rather than the member's
29+
/// cleared state. There is no UI to clear an avatar today, so this is
30+
/// unreachable in practice; it is fully resolved by member-authoritative
31+
/// rendering (`displayAvatar(for:)`) in the ProfilesRepository refactor, when
32+
/// this whole stopgap is removed.
1733
///
1834
/// Interim stopgap: remove once identity resolves from ProfilesRepository
1935
/// (see docs/plans/2026-06-29-profile-table-implementation.md, section 10.1).
2036
static func liveOverride(member: Profile, stored: Contact?) -> Contact {
21-
let hasMemberAvatar = member.avatar != nil
22-
return Contact(
37+
Contact(
2338
inboxId: member.inboxId,
2439
displayName: stored?.displayName,
25-
avatarURL: hasMemberAvatar ? member.avatar : stored?.avatarURL,
26-
avatarSalt: hasMemberAvatar ? member.avatarSalt : stored?.avatarSalt,
27-
avatarNonce: hasMemberAvatar ? member.avatarNonce : stored?.avatarNonce,
28-
avatarKey: hasMemberAvatar ? member.avatarKey : stored?.avatarKey,
40+
avatarURL: member.avatar,
41+
avatarSalt: member.avatarSalt,
42+
avatarNonce: member.avatarNonce,
43+
avatarKey: member.avatarKey,
2944
addedAt: stored?.addedAt ?? Date(),
3045
addedViaConversationId: stored?.addedViaConversationId,
3146
isBlocked: stored?.isBlocked ?? false,
3247
agentVerification: stored?.agentVerification,
3348
agentTemplateId: stored?.agentTemplateId,
3449
agentTemplatePublishedURL: stored?.agentTemplatePublishedURL,
35-
profileEmoji: stored?.profileEmoji
50+
profileEmoji: member.profileEmoji
3651
)
3752
}
3853

Convos/Conversation Detail/ConversationViewModel.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ import SwiftUI
99
import UIKit
1010
import UserNotifications
1111

12+
/// Moves a staged invite image into the URL-keyed byte cache under the finalized
13+
/// invite's real image URL, so the invite card renders it without dropping to a
14+
/// placeholder or re-downloading. No-op when the text has no parseable image URL.
15+
private func cacheFinalizedInviteImage(_ image: UIImage, inviteText: String) {
16+
guard let invite = MessageInvite.from(text: inviteText),
17+
let imageURLString = invite.imageURL?.absoluteString else { return }
18+
ImageCache.shared.cacheAfterUpload(image, for: invite, url: imageURLString)
19+
}
20+
1221
struct PendingInvite {
1322
let code: String
1423
var fullURL: String
@@ -3258,6 +3267,7 @@ extension ConversationViewModel {
32583267
if let updatedInvite = try await metadataWriter.refreshInvite(for: linkedId),
32593268
let pendingMessageId {
32603269
try await messageWriter.finalizeInvite(clientMessageId: pendingMessageId, finalText: updatedInvite.inviteURLString)
3270+
cacheFinalizedInviteImage(image, inviteText: updatedInvite.inviteURLString)
32613271
}
32623272
}
32633273
} catch {

0 commit comments

Comments
 (0)