Fix broken avatar aspect ratio in the share sheet and notifications

The media repo serves thumbnails with the scale method, so avatars keep
their source aspect ratio. The system stretches whatever INImage we
donate to fill a circle, distorting any non-square avatar in the share
sheet's conversation suggestions (and notifications, which are donated
the same image).

Centre-crop donated avatars to a square before handing them to the
system, in both the timeline's send message intent donation and the
NSE's communication context.
This commit is contained in:
Matthew Hodgson
2026-08-03 22:02:08 +03:00
committed by Mauro
parent a82726a991
commit 39805d080e
3 changed files with 29 additions and 3 deletions
@@ -650,8 +650,9 @@ class TimelineController: TimelineControllerProtocol {
}
if let avatarURL, let mediaSource = try? MediaSourceProxy(url: avatarURL, mimeType: nil) {
if case let .success(avatarData) = await mediaProvider.loadThumbnailForSource(source: mediaSource, size: .init(width: 100, height: 100)) {
sendMessageIntent.setImage(INImage(imageData: avatarData), forParameterNamed: \.speakableGroupName)
if case let .success(avatarData) = await mediaProvider.loadThumbnailForSource(source: mediaSource, size: .init(width: 100, height: 100)),
let squareAvatarData = Avatars.squareAvatarImageData(from: avatarData) {
sendMessageIntent.setImage(INImage(imageData: squareAvatarData), forParameterNamed: \.speakableGroupName)
} else {
addPlacehoder()
}