mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Add the inviter to JoinRoomScreen when it's an invite. (#3093)
* Add inviter property to RoomProxyProtocol. * Extract the room cell inviter label into it's own view. * Use the new RoomInviterLabel in the JoinRoomScreen. * Fix bug with invite to a public room.
This commit is contained in:
@@ -144,12 +144,6 @@ struct HomeScreenRoom: Identifiable, Equatable {
|
||||
case invite
|
||||
}
|
||||
|
||||
struct InviterDetails: Equatable {
|
||||
let userID: String
|
||||
let displayName: String?
|
||||
let avatarURL: URL?
|
||||
}
|
||||
|
||||
static let placeholderLastMessage = AttributedString("Hidden last message")
|
||||
|
||||
/// The list item identifier is it's room identifier.
|
||||
@@ -182,7 +176,7 @@ struct HomeScreenRoom: Identifiable, Equatable {
|
||||
|
||||
let avatar: RoomAvatar
|
||||
|
||||
let inviter: InviterDetails?
|
||||
let inviter: RoomInviterDetails?
|
||||
|
||||
let canonicalAlias: String?
|
||||
|
||||
@@ -215,12 +209,7 @@ extension HomeScreenRoom {
|
||||
let isCallShown = summary.hasOngoingCall
|
||||
let isHighlighted = summary.isMarkedUnread || (!summary.isMuted && (summary.hasUnreadNotifications || summary.hasUnreadMentions))
|
||||
|
||||
var inviter: InviterDetails?
|
||||
if let roomMemberProxy = summary.inviter {
|
||||
inviter = .init(userID: roomMemberProxy.userID,
|
||||
displayName: roomMemberProxy.displayName,
|
||||
avatarURL: roomMemberProxy.avatarURL)
|
||||
}
|
||||
let inviter = summary.inviter.map(RoomInviterDetails.init)
|
||||
|
||||
self.init(id: identifier,
|
||||
roomID: summary.id,
|
||||
|
||||
@@ -74,17 +74,10 @@ struct HomeScreenInviteCell: View {
|
||||
|
||||
@ViewBuilder
|
||||
private var inviterView: some View {
|
||||
if let invitedText = attributedInviteText, let name = room.inviter?.displayName {
|
||||
HStack(alignment: .firstTextBaseline, spacing: 8) {
|
||||
LoadableAvatarImage(url: room.inviter?.avatarURL,
|
||||
name: name,
|
||||
contentID: name,
|
||||
avatarSize: .custom(16),
|
||||
imageProvider: context.imageProvider)
|
||||
.alignmentGuide(.firstTextBaseline) { $0[.bottom] * 0.8 }
|
||||
|
||||
Text(invitedText)
|
||||
}
|
||||
if let inviter = room.inviter, !room.isDirect {
|
||||
RoomInviterLabel(inviter: inviter, imageProvider: context.imageProvider)
|
||||
.font(.compound.bodyMD)
|
||||
.foregroundStyle(.compound.textPlaceholder)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,27 +123,7 @@ struct HomeScreenInviteCell: View {
|
||||
}
|
||||
|
||||
private var subtitle: String? {
|
||||
room.isDirect ? room.inviter?.userID : room.canonicalAlias
|
||||
}
|
||||
|
||||
private var attributedInviteText: AttributedString? {
|
||||
guard
|
||||
room.isDirect == false,
|
||||
let inviterName = room.inviter?.displayName,
|
||||
let inviterID = room.inviter?.userID
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let text = L10n.screenInvitesInvitedYou(inviterName, inviterID)
|
||||
var attributedString = AttributedString(text)
|
||||
attributedString.font = .compound.bodyMD
|
||||
attributedString.foregroundColor = .compound.textPlaceholder
|
||||
if let range = attributedString.range(of: inviterName) {
|
||||
attributedString[range].foregroundColor = .compound.textPrimary
|
||||
attributedString[range].font = .compound.bodyMDSemibold
|
||||
}
|
||||
return attributedString
|
||||
room.isDirect ? room.inviter?.id : room.canonicalAlias
|
||||
}
|
||||
|
||||
private var badge: some View {
|
||||
|
||||
Reference in New Issue
Block a user