Pinned events banner loading state (#3118)

This commit is contained in:
Mauro
2024-08-06 15:46:56 +02:00
committed by GitHub
parent 0c9da2cee9
commit 08347e15a5
26 changed files with 468 additions and 113 deletions
@@ -42,6 +42,11 @@ struct RoomEventStringBuilder {
case .redactedMessage:
return prefix(L10n.commonMessageRemoved, with: displayName)
case .sticker:
if messageEventStringBuilder.prefix == .messageType {
var string = AttributedString(L10n.commonSticker)
string.bold()
return string
}
return prefix(L10n.commonSticker, with: displayName)
case .failedToParseMessageLike, .failedToParseState:
return prefix(L10n.commonUnsupportedEvent, with: displayName)
@@ -70,6 +75,14 @@ struct RoomEventStringBuilder {
memberIsYou: isOutgoing)
.map(AttributedString.init)
case .poll(let question, _, _, _, _, _, _):
if messageEventStringBuilder.prefix == .messageType {
let questionPlaceholder = "{question}"
var finalString = AttributedString(L10n.commonPollSummary(questionPlaceholder))
finalString.bold()
let normalString = AttributedString(question)
finalString.replace(questionPlaceholder, with: normalString)
return finalString
}
return prefix(L10n.commonPollSummary(question), with: displayName)
case .callInvite:
return prefix(L10n.commonCallInvite, with: displayName)
@@ -95,7 +108,7 @@ struct RoomEventStringBuilder {
RoomEventStringBuilder(stateEventStringBuilder: .init(userID: userID,
shouldDisambiguateDisplayNames: false),
messageEventStringBuilder: .init(attributedStringBuilder: AttributedStringBuilder(cacheKey: "pinnedEvents", mentionBuilder: PlainMentionBuilder()),
prefix: .mediaType),
prefix: .messageType),
shouldDisambiguateDisplayNames: false,
shouldPrefixSenderName: false)
}
@@ -20,7 +20,7 @@ import MatrixRustSDK
struct RoomMessageEventStringBuilder {
enum Prefix {
case senderName
case mediaType
case messageType
case none
}
@@ -41,19 +41,19 @@ struct RoomMessageEventStringBuilder {
case .audio(content: let content):
let isVoiceMessage = content.voice != nil
var content = AttributedString(isVoiceMessage ? L10n.commonVoiceMessage : L10n.commonAudio)
if prefix == .mediaType {
if prefix == .messageType {
content.bold()
}
message = content
case .image(let content):
message = prefix == .mediaType ? prefix(AttributedString(content.body), with: L10n.commonImage) : AttributedString("\(L10n.commonImage) - \(content.body)")
message = prefix == .messageType ? prefix(AttributedString(content.body), with: L10n.commonImage) : AttributedString("\(L10n.commonImage) - \(content.body)")
case .video(let content):
message = prefix == .mediaType ? prefix(AttributedString(content.body), with: L10n.commonVideo) : AttributedString("\(L10n.commonVideo) - \(content.body)")
message = prefix == .messageType ? prefix(AttributedString(content.body), with: L10n.commonVideo) : AttributedString("\(L10n.commonVideo) - \(content.body)")
case .file(let content):
message = prefix == .mediaType ? prefix(AttributedString(content.body), with: L10n.commonFile) : AttributedString("\(L10n.commonFile) - \(content.body)")
message = prefix == .messageType ? prefix(AttributedString(content.body), with: L10n.commonFile) : AttributedString("\(L10n.commonFile) - \(content.body)")
case .location:
var content = AttributedString(L10n.commonSharedLocation)
if prefix == .mediaType {
if prefix == .messageType {
content.bold()
}
message = content