mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Render Room and Message Pills (#3809)
* added a way to render the room and the message pills, but is WIP * permalinks now get converted into pills! * fixed an issue where room address mentions were not adding a URL properly but a string * updated tests * c * Revert "c" This reverts commit 5c80252fa23dba7e4d44f2a07fbf1e9500e37c82. * updated tests * more tests * created APIs to get a specific RoomSummary given the id or the alias * small mention builder improvement * pr suggestions
This commit is contained in:
@@ -3225,6 +3225,146 @@ class ClientProxyMock: ClientProxyProtocol, @unchecked Sendable {
|
||||
return roomPreviewForIdentifierViaReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - roomSummaryForIdentifier
|
||||
|
||||
var roomSummaryForIdentifierUnderlyingCallsCount = 0
|
||||
var roomSummaryForIdentifierCallsCount: Int {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return roomSummaryForIdentifierUnderlyingCallsCount
|
||||
} else {
|
||||
var returnValue: Int? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = roomSummaryForIdentifierUnderlyingCallsCount
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
roomSummaryForIdentifierUnderlyingCallsCount = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
roomSummaryForIdentifierUnderlyingCallsCount = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var roomSummaryForIdentifierCalled: Bool {
|
||||
return roomSummaryForIdentifierCallsCount > 0
|
||||
}
|
||||
var roomSummaryForIdentifierReceivedIdentifier: String?
|
||||
var roomSummaryForIdentifierReceivedInvocations: [String] = []
|
||||
|
||||
var roomSummaryForIdentifierUnderlyingReturnValue: RoomSummary?
|
||||
var roomSummaryForIdentifierReturnValue: RoomSummary? {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return roomSummaryForIdentifierUnderlyingReturnValue
|
||||
} else {
|
||||
var returnValue: RoomSummary?? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = roomSummaryForIdentifierUnderlyingReturnValue
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
roomSummaryForIdentifierUnderlyingReturnValue = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
roomSummaryForIdentifierUnderlyingReturnValue = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var roomSummaryForIdentifierClosure: ((String) -> RoomSummary?)?
|
||||
|
||||
func roomSummaryForIdentifier(_ identifier: String) -> RoomSummary? {
|
||||
roomSummaryForIdentifierCallsCount += 1
|
||||
roomSummaryForIdentifierReceivedIdentifier = identifier
|
||||
DispatchQueue.main.async {
|
||||
self.roomSummaryForIdentifierReceivedInvocations.append(identifier)
|
||||
}
|
||||
if let roomSummaryForIdentifierClosure = roomSummaryForIdentifierClosure {
|
||||
return roomSummaryForIdentifierClosure(identifier)
|
||||
} else {
|
||||
return roomSummaryForIdentifierReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - roomSummaryForAlias
|
||||
|
||||
var roomSummaryForAliasUnderlyingCallsCount = 0
|
||||
var roomSummaryForAliasCallsCount: Int {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return roomSummaryForAliasUnderlyingCallsCount
|
||||
} else {
|
||||
var returnValue: Int? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = roomSummaryForAliasUnderlyingCallsCount
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
roomSummaryForAliasUnderlyingCallsCount = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
roomSummaryForAliasUnderlyingCallsCount = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var roomSummaryForAliasCalled: Bool {
|
||||
return roomSummaryForAliasCallsCount > 0
|
||||
}
|
||||
var roomSummaryForAliasReceivedAlias: String?
|
||||
var roomSummaryForAliasReceivedInvocations: [String] = []
|
||||
|
||||
var roomSummaryForAliasUnderlyingReturnValue: RoomSummary?
|
||||
var roomSummaryForAliasReturnValue: RoomSummary? {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return roomSummaryForAliasUnderlyingReturnValue
|
||||
} else {
|
||||
var returnValue: RoomSummary?? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = roomSummaryForAliasUnderlyingReturnValue
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
roomSummaryForAliasUnderlyingReturnValue = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
roomSummaryForAliasUnderlyingReturnValue = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var roomSummaryForAliasClosure: ((String) -> RoomSummary?)?
|
||||
|
||||
func roomSummaryForAlias(_ alias: String) -> RoomSummary? {
|
||||
roomSummaryForAliasCallsCount += 1
|
||||
roomSummaryForAliasReceivedAlias = alias
|
||||
DispatchQueue.main.async {
|
||||
self.roomSummaryForAliasReceivedInvocations.append(alias)
|
||||
}
|
||||
if let roomSummaryForAliasClosure = roomSummaryForAliasClosure {
|
||||
return roomSummaryForAliasClosure(alias)
|
||||
} else {
|
||||
return roomSummaryForAliasReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - loadUserDisplayName
|
||||
|
||||
var loadUserDisplayNameUnderlyingCallsCount = 0
|
||||
|
||||
@@ -67,6 +67,31 @@ extension RoomSummaryProviderMock {
|
||||
}
|
||||
}
|
||||
|
||||
extension RoomSummary {
|
||||
static func mock(id: String,
|
||||
name: String,
|
||||
canonicalAlias: String? = nil) -> RoomSummary {
|
||||
RoomSummary(roomListItem: RoomListItemSDKMock(),
|
||||
id: id,
|
||||
joinRequestType: nil,
|
||||
name: name,
|
||||
isDirect: false,
|
||||
avatarURL: nil,
|
||||
heroes: [],
|
||||
lastMessage: AttributedString("I do not wish to take the trouble to understand mysticism"),
|
||||
lastMessageFormattedTimestamp: "14:56",
|
||||
unreadMessagesCount: 0,
|
||||
unreadMentionsCount: 0,
|
||||
unreadNotificationsCount: 0,
|
||||
notificationMode: .allMessages,
|
||||
canonicalAlias: canonicalAlias,
|
||||
alternativeAliases: [],
|
||||
hasOngoingCall: false,
|
||||
isMarkedUnread: false,
|
||||
isFavourite: false)
|
||||
}
|
||||
}
|
||||
|
||||
extension Array where Element == RoomSummary {
|
||||
static let mockRooms: [Element] = [
|
||||
RoomSummary(roomListItem: RoomListItemSDKMock(),
|
||||
@@ -83,6 +108,7 @@ extension Array where Element == RoomSummary {
|
||||
unreadNotificationsCount: 0,
|
||||
notificationMode: .allMessages,
|
||||
canonicalAlias: nil,
|
||||
alternativeAliases: [],
|
||||
hasOngoingCall: false,
|
||||
isMarkedUnread: false,
|
||||
isFavourite: false),
|
||||
@@ -99,7 +125,8 @@ extension Array where Element == RoomSummary {
|
||||
unreadMentionsCount: 0,
|
||||
unreadNotificationsCount: 2,
|
||||
notificationMode: .mute,
|
||||
canonicalAlias: nil,
|
||||
canonicalAlias: "#foundation-and-empire:matrix.org",
|
||||
alternativeAliases: [],
|
||||
hasOngoingCall: false,
|
||||
isMarkedUnread: false,
|
||||
isFavourite: false),
|
||||
@@ -117,6 +144,7 @@ extension Array where Element == RoomSummary {
|
||||
unreadNotificationsCount: 0,
|
||||
notificationMode: .mentionsAndKeywordsOnly,
|
||||
canonicalAlias: nil,
|
||||
alternativeAliases: [],
|
||||
hasOngoingCall: false,
|
||||
isMarkedUnread: false,
|
||||
isFavourite: false),
|
||||
@@ -134,6 +162,7 @@ extension Array where Element == RoomSummary {
|
||||
unreadNotificationsCount: 2,
|
||||
notificationMode: .allMessages,
|
||||
canonicalAlias: nil,
|
||||
alternativeAliases: [],
|
||||
hasOngoingCall: false,
|
||||
isMarkedUnread: false,
|
||||
isFavourite: false),
|
||||
@@ -151,6 +180,7 @@ extension Array where Element == RoomSummary {
|
||||
unreadNotificationsCount: 1,
|
||||
notificationMode: .allMessages,
|
||||
canonicalAlias: nil,
|
||||
alternativeAliases: [],
|
||||
hasOngoingCall: true,
|
||||
isMarkedUnread: false,
|
||||
isFavourite: false),
|
||||
@@ -168,6 +198,7 @@ extension Array where Element == RoomSummary {
|
||||
unreadNotificationsCount: 0,
|
||||
notificationMode: .mute,
|
||||
canonicalAlias: nil,
|
||||
alternativeAliases: [],
|
||||
hasOngoingCall: true,
|
||||
isMarkedUnread: false,
|
||||
isFavourite: false),
|
||||
@@ -185,6 +216,7 @@ extension Array where Element == RoomSummary {
|
||||
unreadNotificationsCount: 0,
|
||||
notificationMode: nil,
|
||||
canonicalAlias: nil,
|
||||
alternativeAliases: [],
|
||||
hasOngoingCall: false,
|
||||
isMarkedUnread: false,
|
||||
isFavourite: false)
|
||||
@@ -235,6 +267,7 @@ extension Array where Element == RoomSummary {
|
||||
unreadNotificationsCount: 0,
|
||||
notificationMode: nil,
|
||||
canonicalAlias: "#footest:somewhere.org",
|
||||
alternativeAliases: [],
|
||||
hasOngoingCall: false,
|
||||
isMarkedUnread: false,
|
||||
isFavourite: false),
|
||||
@@ -252,6 +285,7 @@ extension Array where Element == RoomSummary {
|
||||
unreadNotificationsCount: 0,
|
||||
notificationMode: nil,
|
||||
canonicalAlias: nil,
|
||||
alternativeAliases: [],
|
||||
hasOngoingCall: false,
|
||||
isMarkedUnread: false,
|
||||
isFavourite: false)
|
||||
|
||||
Reference in New Issue
Block a user