mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
MentionBadge FF (#2281)
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
|
||||
enum RoomNotificationModeProxy {
|
||||
enum RoomNotificationModeProxy: String {
|
||||
case allMessages
|
||||
case mentionsAndKeywordsOnly
|
||||
case mute
|
||||
|
||||
@@ -83,7 +83,8 @@ extension Array where Element == RoomSummary {
|
||||
avatarURL: nil,
|
||||
lastMessage: AttributedString("I do not wish to take the trouble to understand mysticism"),
|
||||
lastMessageFormattedTimestamp: "14:56",
|
||||
unreadNotificationCount: 0,
|
||||
unreadMessagesCount: 0,
|
||||
unreadMentionsCount: 0,
|
||||
notificationMode: .allMessages,
|
||||
canonicalAlias: nil,
|
||||
inviter: nil,
|
||||
@@ -94,7 +95,8 @@ extension Array where Element == RoomSummary {
|
||||
avatarURL: URL.picturesDirectory,
|
||||
lastMessage: AttributedString("How do you see the Emperor then? You think he keeps office hours?"),
|
||||
lastMessageFormattedTimestamp: "2:56 PM",
|
||||
unreadNotificationCount: 2,
|
||||
unreadMessagesCount: 2,
|
||||
unreadMentionsCount: 0,
|
||||
notificationMode: .mute,
|
||||
canonicalAlias: nil,
|
||||
inviter: nil,
|
||||
@@ -105,7 +107,8 @@ extension Array where Element == RoomSummary {
|
||||
avatarURL: nil,
|
||||
lastMessage: try? AttributedString(markdown: "He certainly seemed no *mental genius* to me"),
|
||||
lastMessageFormattedTimestamp: "Some time ago",
|
||||
unreadNotificationCount: 3,
|
||||
unreadMessagesCount: 3,
|
||||
unreadMentionsCount: 0,
|
||||
notificationMode: .mentionsAndKeywordsOnly,
|
||||
canonicalAlias: nil,
|
||||
inviter: nil,
|
||||
@@ -116,7 +119,8 @@ extension Array where Element == RoomSummary {
|
||||
avatarURL: nil,
|
||||
lastMessage: AttributedString("There's an archaic measure of time that's called the month"),
|
||||
lastMessageFormattedTimestamp: "Just now",
|
||||
unreadNotificationCount: 4,
|
||||
unreadMessagesCount: 2,
|
||||
unreadMentionsCount: 2,
|
||||
notificationMode: .allMessages,
|
||||
canonicalAlias: nil,
|
||||
inviter: nil,
|
||||
@@ -127,7 +131,8 @@ extension Array where Element == RoomSummary {
|
||||
avatarURL: nil,
|
||||
lastMessage: AttributedString("Clearly, if Earth is powerful enough to do that, it might also be capable of adjusting minds in order to force belief in its radioactivity"),
|
||||
lastMessageFormattedTimestamp: "1986",
|
||||
unreadNotificationCount: 5,
|
||||
unreadMessagesCount: 1,
|
||||
unreadMentionsCount: 1,
|
||||
notificationMode: .allMessages,
|
||||
canonicalAlias: nil,
|
||||
inviter: nil,
|
||||
@@ -138,7 +143,8 @@ extension Array where Element == RoomSummary {
|
||||
avatarURL: nil,
|
||||
lastMessage: AttributedString("Are you groping for the word 'paranoia'?"),
|
||||
lastMessageFormattedTimestamp: "きょうはじゅういちがつじゅういちにちです",
|
||||
unreadNotificationCount: 6,
|
||||
unreadMessagesCount: 6,
|
||||
unreadMentionsCount: 0,
|
||||
notificationMode: .mute,
|
||||
canonicalAlias: nil,
|
||||
inviter: nil,
|
||||
@@ -149,7 +155,8 @@ extension Array where Element == RoomSummary {
|
||||
avatarURL: nil,
|
||||
lastMessage: nil,
|
||||
lastMessageFormattedTimestamp: nil,
|
||||
unreadNotificationCount: 0,
|
||||
unreadMessagesCount: 0,
|
||||
unreadMentionsCount: 0,
|
||||
notificationMode: nil,
|
||||
canonicalAlias: nil,
|
||||
inviter: nil,
|
||||
@@ -157,13 +164,65 @@ extension Array where Element == RoomSummary {
|
||||
.empty
|
||||
]
|
||||
|
||||
static let mockRoomsWithNotificationsState: [Element] = [
|
||||
.filled(details: RoomSummaryDetails(id: "1",
|
||||
settingsMode: .allMessages,
|
||||
hasUnreadMessages: false,
|
||||
hasUnreadMentions: false)),
|
||||
.filled(details: RoomSummaryDetails(id: "2",
|
||||
settingsMode: .allMessages,
|
||||
hasUnreadMessages: true,
|
||||
hasUnreadMentions: false)),
|
||||
.filled(details: RoomSummaryDetails(id: "3",
|
||||
settingsMode: .allMessages,
|
||||
hasUnreadMessages: true,
|
||||
hasUnreadMentions: true)),
|
||||
.filled(details: RoomSummaryDetails(id: "4",
|
||||
settingsMode: .allMessages,
|
||||
hasUnreadMessages: false,
|
||||
hasUnreadMentions: true)),
|
||||
.filled(details: RoomSummaryDetails(id: "5",
|
||||
settingsMode: .mentionsAndKeywordsOnly,
|
||||
hasUnreadMessages: false,
|
||||
hasUnreadMentions: false)),
|
||||
.filled(details: RoomSummaryDetails(id: "6",
|
||||
settingsMode: .mentionsAndKeywordsOnly,
|
||||
hasUnreadMessages: true,
|
||||
hasUnreadMentions: false)),
|
||||
.filled(details: RoomSummaryDetails(id: "7",
|
||||
settingsMode: .mentionsAndKeywordsOnly,
|
||||
hasUnreadMessages: true,
|
||||
hasUnreadMentions: true)),
|
||||
.filled(details: RoomSummaryDetails(id: "8",
|
||||
settingsMode: .mentionsAndKeywordsOnly,
|
||||
hasUnreadMessages: false,
|
||||
hasUnreadMentions: true)),
|
||||
.filled(details: RoomSummaryDetails(id: "9",
|
||||
settingsMode: .mute,
|
||||
hasUnreadMessages: false,
|
||||
hasUnreadMentions: false)),
|
||||
.filled(details: RoomSummaryDetails(id: "10",
|
||||
settingsMode: .mute,
|
||||
hasUnreadMessages: true,
|
||||
hasUnreadMentions: false)),
|
||||
.filled(details: RoomSummaryDetails(id: "11",
|
||||
settingsMode: .mute,
|
||||
hasUnreadMessages: true,
|
||||
hasUnreadMentions: true)),
|
||||
.filled(details: RoomSummaryDetails(id: "12",
|
||||
settingsMode: .mute,
|
||||
hasUnreadMessages: false,
|
||||
hasUnreadMentions: true))
|
||||
]
|
||||
|
||||
static let mockInvites: [Element] = [
|
||||
.filled(details: RoomSummaryDetails(id: "someAwesomeRoomId1", name: "First room",
|
||||
isDirect: false,
|
||||
avatarURL: URL.picturesDirectory,
|
||||
lastMessage: nil,
|
||||
lastMessageFormattedTimestamp: nil,
|
||||
unreadNotificationCount: 0,
|
||||
unreadMessagesCount: 0,
|
||||
unreadMentionsCount: 0,
|
||||
notificationMode: nil,
|
||||
canonicalAlias: "#footest:somewhere.org",
|
||||
inviter: RoomMemberProxyMock.mockCharlie,
|
||||
@@ -174,7 +233,8 @@ extension Array where Element == RoomSummary {
|
||||
avatarURL: nil,
|
||||
lastMessage: nil,
|
||||
lastMessageFormattedTimestamp: nil,
|
||||
unreadNotificationCount: 0,
|
||||
unreadMessagesCount: 0,
|
||||
unreadMentionsCount: 0,
|
||||
notificationMode: nil,
|
||||
canonicalAlias: nil,
|
||||
inviter: RoomMemberProxyMock.mockCharlie,
|
||||
|
||||
@@ -24,7 +24,8 @@ struct RoomSummaryDetails {
|
||||
let avatarURL: URL?
|
||||
let lastMessage: AttributedString?
|
||||
let lastMessageFormattedTimestamp: String?
|
||||
let unreadNotificationCount: UInt
|
||||
let unreadMessagesCount: UInt
|
||||
let unreadMentionsCount: UInt
|
||||
let notificationMode: RoomNotificationModeProxy?
|
||||
let canonicalAlias: String?
|
||||
let inviter: RoomMemberProxyProtocol?
|
||||
@@ -33,6 +34,24 @@ struct RoomSummaryDetails {
|
||||
|
||||
extension RoomSummaryDetails: CustomStringConvertible {
|
||||
var description: String {
|
||||
"id: \"\(id)\", isDirect: \"\(isDirect)\", unreadNotificationCount: \"\(unreadNotificationCount)\""
|
||||
"RoomSummaryDetails: - id: \(id) - isDirect: \(isDirect) - unreadMessagesCount: \(unreadMessagesCount) - unreadMentionsCount: \(unreadMentionsCount) - notificationMode: \(notificationMode?.rawValue ?? "nil")"
|
||||
}
|
||||
}
|
||||
|
||||
extension RoomSummaryDetails {
|
||||
init(id: String, settingsMode: RoomNotificationModeProxy, hasUnreadMessages: Bool, hasUnreadMentions: Bool) {
|
||||
self.id = id
|
||||
let string = "\(settingsMode) - hasUnreadMessages: \(hasUnreadMessages) - hasUnreadMentions: \(hasUnreadMentions)"
|
||||
name = string
|
||||
isDirect = true
|
||||
avatarURL = nil
|
||||
lastMessage = AttributedString(string)
|
||||
lastMessageFormattedTimestamp = "Now"
|
||||
unreadMessagesCount = hasUnreadMessages ? 1 : 0
|
||||
unreadMentionsCount = hasUnreadMentions ? 1 : 0
|
||||
notificationMode = settingsMode
|
||||
canonicalAlias = nil
|
||||
inviter = nil
|
||||
hasOngoingCall = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,7 +245,8 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
|
||||
avatarURL: roomInfo.avatarUrl.flatMap(URL.init(string:)),
|
||||
lastMessage: attributedLastMessage,
|
||||
lastMessageFormattedTimestamp: lastMessageFormattedTimestamp,
|
||||
unreadNotificationCount: UInt(roomInfo.notificationCount),
|
||||
unreadMessagesCount: UInt(roomInfo.notificationCount),
|
||||
unreadMentionsCount: UInt(roomInfo.numUnreadMentions),
|
||||
notificationMode: notificationMode,
|
||||
canonicalAlias: roomInfo.canonicalAlias,
|
||||
inviter: inviterProxy,
|
||||
|
||||
Reference in New Issue
Block a user