Display whether a call is ongoing in any particular room on the room list

This commit is contained in:
Stefan Ceriu
2023-11-10 17:46:55 +02:00
committed by Stefan Ceriu
parent 2e1b4cb80b
commit 5c4e0bd76d
28 changed files with 66 additions and 60 deletions
@@ -1861,11 +1861,11 @@ class RoomProxyMock: RoomProxyProtocol {
set(value) { underlyingIsTombstoned = value } set(value) { underlyingIsTombstoned = value }
} }
var underlyingIsTombstoned: Bool! var underlyingIsTombstoned: Bool!
var isCallOngoing: Bool { var hasOngoingCall: Bool {
get { return underlyingIsCallOngoing } get { return underlyingHasOngoingCall }
set(value) { underlyingIsCallOngoing = value } set(value) { underlyingHasOngoingCall = value }
} }
var underlyingIsCallOngoing: Bool! var underlyingHasOngoingCall: Bool!
var canonicalAlias: String? var canonicalAlias: String?
var alternativeAliases: [String] = [] var alternativeAliases: [String] = []
var hasUnreadNotifications: Bool { var hasUnreadNotifications: Bool {
+2 -2
View File
@@ -28,7 +28,7 @@ struct RoomProxyMockConfiguration {
var isPublic = Bool.random() var isPublic = Bool.random()
var isEncrypted = Bool.random() var isEncrypted = Bool.random()
var isTombstoned = Bool.random() var isTombstoned = Bool.random()
var isCallOngoing = false var hasOngoingCall = false
var canonicalAlias: String? var canonicalAlias: String?
var alternativeAliases: [String] = [] var alternativeAliases: [String] = []
var hasUnreadNotifications = Bool.random() var hasUnreadNotifications = Bool.random()
@@ -57,7 +57,7 @@ extension RoomProxyMock {
isPublic = configuration.isPublic isPublic = configuration.isPublic
isEncrypted = configuration.isEncrypted isEncrypted = configuration.isEncrypted
isTombstoned = configuration.isTombstoned isTombstoned = configuration.isTombstoned
isCallOngoing = configuration.isCallOngoing hasOngoingCall = configuration.hasOngoingCall
canonicalAlias = configuration.canonicalAlias canonicalAlias = configuration.canonicalAlias
alternativeAliases = configuration.alternativeAliases alternativeAliases = configuration.alternativeAliases
hasUnreadNotifications = configuration.hasUnreadNotifications hasUnreadNotifications = configuration.hasUnreadNotifications
@@ -124,6 +124,8 @@ struct HomeScreenRoom: Identifiable, Equatable {
var hasUnreads = false var hasUnreads = false
var hasOngoingCall = false
var timestamp: String? var timestamp: String?
var lastMessage: AttributedString? var lastMessage: AttributedString?
@@ -132,12 +134,6 @@ struct HomeScreenRoom: Identifiable, Equatable {
var notificationMode: RoomNotificationModeProxy? var notificationMode: RoomNotificationModeProxy?
var hasDecoration: Bool {
// notification setting is displayed only for .mentionsAndKeywords and .mute
let showNotificationSettings = notificationMode != nil
return hasUnreads || showNotificationSettings
}
var isPlaceholder = false var isPlaceholder = false
static func placeholder() -> HomeScreenRoom { static func placeholder() -> HomeScreenRoom {
@@ -311,6 +311,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
roomId: details.id, roomId: details.id,
name: details.name, name: details.name,
hasUnreads: details.unreadNotificationCount > 0, hasUnreads: details.unreadNotificationCount > 0,
hasOngoingCall: details.hasOngoingCall,
timestamp: details.lastMessageFormattedTimestamp, timestamp: details.lastMessageFormattedTimestamp,
lastMessage: details.lastMessage, lastMessage: details.lastMessage,
avatarURL: details.avatarURL, avatarURL: details.avatarURL,
@@ -117,6 +117,11 @@ struct HomeScreenRoomCell: View {
Spacer() Spacer()
HStack(spacing: 8) { HStack(spacing: 8) {
if room.hasOngoingCall {
CompoundIcon(\.videoCallSolid, size: .xSmall, relativeTo: .compound.bodySM)
.foregroundColor(room.hasUnreads ? .compound.iconAccentTertiary : .compound.iconQuaternary)
}
notificationModeIcon notificationModeIcon
.foregroundColor(room.hasUnreads ? .compound.iconAccentTertiary : .compound.iconQuaternary) .foregroundColor(room.hasUnreads ? .compound.iconAccentTertiary : .compound.iconQuaternary)
@@ -125,15 +130,7 @@ struct HomeScreenRoomCell: View {
.frame(width: 12, height: 12) .frame(width: 12, height: 12)
.foregroundColor(.compound.iconAccentTertiary) .foregroundColor(.compound.iconAccentTertiary)
} }
if !room.hasDecoration {
// Force extra padding between last message text and the right border of the screen if there is no unread dot
Circle()
.frame(width: 12, height: 12)
.hidden()
}
} }
.padding(.leading, room.hasDecoration ? 12 : 0)
} }
} }
@@ -205,6 +202,7 @@ struct HomeScreenRoomCell_Previews: PreviewProvider, TestablePreview {
roomId: details.id, roomId: details.id,
name: details.name, name: details.name,
hasUnreads: details.unreadNotificationCount > 0, hasUnreads: details.unreadNotificationCount > 0,
hasOngoingCall: details.hasOngoingCall,
timestamp: Date(timeIntervalSinceReferenceDate: 0).formattedMinimal(), timestamp: Date(timeIntervalSinceReferenceDate: 0).formattedMinimal(),
lastMessage: details.lastMessage, lastMessage: details.lastMessage,
notificationMode: details.notificationMode) notificationMode: details.notificationMode)
@@ -191,7 +191,8 @@ private extension InvitesScreenRoomDetails {
unreadNotificationCount: 0, unreadNotificationCount: 0,
notificationMode: nil, notificationMode: nil,
canonicalAlias: "#footest:somewhere.org", canonicalAlias: "#footest:somewhere.org",
inviter: inviter) inviter: inviter,
hasOngoingCall: false)
return .init(roomDetails: dmRoom, isUnread: false) return .init(roomDetails: dmRoom, isUnread: false)
} }
@@ -210,7 +211,8 @@ private extension InvitesScreenRoomDetails {
unreadNotificationCount: 0, unreadNotificationCount: 0,
notificationMode: nil, notificationMode: nil,
canonicalAlias: alias, canonicalAlias: alias,
inviter: inviter) inviter: inviter,
hasOngoingCall: false)
return .init(roomDetails: dmRoom, isUnread: isUnread) return .init(roomDetails: dmRoom, isUnread: isUnread)
} }
} }
@@ -126,7 +126,7 @@ struct RoomScreenViewState: BindableState {
var ownUserID: String var ownUserID: String
var isCallOngoing = false var hasOngoingCall = false
var bindings: RoomScreenViewStateBindings var bindings: RoomScreenViewStateBindings
@@ -87,7 +87,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
readReceiptsEnabled: appSettings.readReceiptsEnabled, readReceiptsEnabled: appSettings.readReceiptsEnabled,
isEncryptedOneToOneRoom: roomProxy.isEncryptedOneToOneRoom, isEncryptedOneToOneRoom: roomProxy.isEncryptedOneToOneRoom,
ownUserID: roomProxy.ownUserID, ownUserID: roomProxy.ownUserID,
isCallOngoing: roomProxy.isCallOngoing, hasOngoingCall: roomProxy.hasOngoingCall,
bindings: .init(reactionsCollapsed: [:])), bindings: .init(reactionsCollapsed: [:])),
imageProvider: mediaProvider) imageProvider: mediaProvider)
@@ -281,7 +281,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
guard let self else { return } guard let self else { return }
self.state.roomTitle = roomProxy.roomTitle self.state.roomTitle = roomProxy.roomTitle
self.state.roomAvatarURL = roomProxy.avatarURL self.state.roomAvatarURL = roomProxy.avatarURL
self.state.isCallOngoing = roomProxy.isCallOngoing self.state.hasOngoingCall = roomProxy.hasOngoingCall
} }
.store(in: &cancellables) .store(in: &cancellables)
@@ -164,7 +164,7 @@ struct RoomScreen: View {
@ViewBuilder @ViewBuilder
private var callButton: some View { private var callButton: some View {
if context.viewState.isCallOngoing { if context.viewState.hasOngoingCall {
Button { Button {
context.send(viewAction: .presentCall) context.send(viewAction: .presentCall)
} label: { } label: {
@@ -189,7 +189,7 @@ struct RoomScreen: View {
// MARK: - Previews // MARK: - Previews
struct RoomScreen_Previews: PreviewProvider, TestablePreview { struct RoomScreen_Previews: PreviewProvider, TestablePreview {
static let viewModel = RoomScreenViewModel(roomProxy: RoomProxyMock(with: .init(displayName: "Preview room", isCallOngoing: true)), static let viewModel = RoomScreenViewModel(roomProxy: RoomProxyMock(with: .init(displayName: "Preview room", hasOngoingCall: true)),
timelineController: MockRoomTimelineController(), timelineController: MockRoomTimelineController(),
mediaProvider: MockMediaProvider(), mediaProvider: MockMediaProvider(),
mediaPlayerProvider: MediaPlayerProviderMock(), mediaPlayerProvider: MediaPlayerProviderMock(),
@@ -24,6 +24,7 @@ struct SeparatorRoomTimelineView: View {
.font(.compound.bodySMSemibold) .font(.compound.bodySMSemibold)
.foregroundColor(.compound.textPrimary) .foregroundColor(.compound.textPrimary)
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.multilineTextAlignment(.center)
.padding(.horizontal, 36.0) .padding(.horizontal, 36.0)
.padding(.vertical, 8.0) .padding(.vertical, 8.0)
} }
@@ -151,7 +151,7 @@ class RoomProxy: RoomProxyProtocol {
room.isTombstoned() room.isTombstoned()
} }
var isCallOngoing: Bool { var hasOngoingCall: Bool {
room.hasActiveRoomCall() room.hasActiveRoomCall()
} }
@@ -55,7 +55,7 @@ protocol RoomProxyProtocol {
var isSpace: Bool { get } var isSpace: Bool { get }
var isEncrypted: Bool { get } var isEncrypted: Bool { get }
var isTombstoned: Bool { get } var isTombstoned: Bool { get }
var isCallOngoing: Bool { get } var hasOngoingCall: Bool { get }
var canonicalAlias: String? { get } var canonicalAlias: String? { get }
var alternativeAliases: [String] { get } var alternativeAliases: [String] { get }
var hasUnreadNotifications: Bool { get } var hasUnreadNotifications: Bool { get }
@@ -85,7 +85,8 @@ extension Array where Element == RoomSummary {
unreadNotificationCount: 4, unreadNotificationCount: 4,
notificationMode: .allMessages, notificationMode: .allMessages,
canonicalAlias: nil, canonicalAlias: nil,
inviter: RoomMemberProxyMock.mockCharlie)), inviter: RoomMemberProxyMock.mockCharlie,
hasOngoingCall: true)),
.filled(details: RoomSummaryDetails(id: "2", .filled(details: RoomSummaryDetails(id: "2",
name: "Second room", name: "Second room",
isDirect: true, isDirect: true,
@@ -95,7 +96,8 @@ extension Array where Element == RoomSummary {
unreadNotificationCount: 1, unreadNotificationCount: 1,
notificationMode: .mentionsAndKeywordsOnly, notificationMode: .mentionsAndKeywordsOnly,
canonicalAlias: nil, canonicalAlias: nil,
inviter: RoomMemberProxyMock.mockCharlie)), inviter: RoomMemberProxyMock.mockCharlie,
hasOngoingCall: false)),
.filled(details: RoomSummaryDetails(id: "3", .filled(details: RoomSummaryDetails(id: "3",
name: "Third room", name: "Third room",
isDirect: true, isDirect: true,
@@ -105,7 +107,8 @@ extension Array where Element == RoomSummary {
unreadNotificationCount: 0, unreadNotificationCount: 0,
notificationMode: .mute, notificationMode: .mute,
canonicalAlias: nil, canonicalAlias: nil,
inviter: RoomMemberProxyMock.mockCharlie)), inviter: RoomMemberProxyMock.mockCharlie,
hasOngoingCall: false)),
.empty .empty
] ]
@@ -118,7 +121,8 @@ extension Array where Element == RoomSummary {
unreadNotificationCount: 0, unreadNotificationCount: 0,
notificationMode: nil, notificationMode: nil,
canonicalAlias: "#footest:somewhere.org", canonicalAlias: "#footest:somewhere.org",
inviter: RoomMemberProxyMock.mockCharlie)), inviter: RoomMemberProxyMock.mockCharlie,
hasOngoingCall: false)),
.filled(details: RoomSummaryDetails(id: "someAwesomeRoomId2", .filled(details: RoomSummaryDetails(id: "someAwesomeRoomId2",
name: "Second room", name: "Second room",
isDirect: true, isDirect: true,
@@ -128,6 +132,7 @@ extension Array where Element == RoomSummary {
unreadNotificationCount: 0, unreadNotificationCount: 0,
notificationMode: nil, notificationMode: nil,
canonicalAlias: nil, canonicalAlias: nil,
inviter: RoomMemberProxyMock.mockCharlie)) inviter: RoomMemberProxyMock.mockCharlie,
hasOngoingCall: false))
] ]
} }
@@ -28,6 +28,7 @@ struct RoomSummaryDetails {
let notificationMode: RoomNotificationModeProxy? let notificationMode: RoomNotificationModeProxy?
let canonicalAlias: String? let canonicalAlias: String?
let inviter: RoomMemberProxyProtocol? let inviter: RoomMemberProxyProtocol?
let hasOngoingCall: Bool
} }
extension RoomSummaryDetails: CustomStringConvertible { extension RoomSummaryDetails: CustomStringConvertible {
@@ -248,7 +248,8 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
unreadNotificationCount: UInt(roomInfo.notificationCount), unreadNotificationCount: UInt(roomInfo.notificationCount),
notificationMode: notificationMode, notificationMode: notificationMode,
canonicalAlias: roomInfo.canonicalAlias, canonicalAlias: roomInfo.canonicalAlias,
inviter: inviterProxy) inviter: inviterProxy,
hasOngoingCall: roomInfo.hasRoomCall)
return invalidated ? .invalidated(details: details) : .filled(details: details) return invalidated ? .invalidated(details: details) : .filled(details: details)
} }
+2 -1
View File
@@ -232,7 +232,8 @@ class LoggingTests: XCTestCase {
unreadNotificationCount: 0, unreadNotificationCount: 0,
notificationMode: nil, notificationMode: nil,
canonicalAlias: nil, canonicalAlias: nil,
inviter: nil) inviter: nil,
hasOngoingCall: false)
// When logging that value // When logging that value
XCTAssert(MXLogger.logFiles.isEmpty) XCTAssert(MXLogger.logFiles.isEmpty)
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:185b067a2b70566df2fce8f0b3e7d2f5e99e1ff13beb5c995cae1b7f68d1dc17 oid sha256:036b3bb2926f55e4a495fa361f086a9af17d119f528550f8c8015ca96005ad9d
size 160653 size 161158
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:8c8d4cd85c146072f2541356426acf0e24ea2171c115c30311da7ff9d424d00a oid sha256:c8590e3d0c40592bb2611482a375756833a6ca0aff046a6239a5358fb1a68735
size 125182 size 125789
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:1b4a59bfa03e0dcc4eda36bc0158f262d47c026cec3e79a05d7047406b6b1fb1 oid sha256:6a7df918bec466c1b9d78669a9bacc4cd8b06987258529e4b8151211a4fea980
size 62574 size 74031
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:f8b9cc5f7c38d3c97c2848d053c9822b39ee47c2ec30f87929c784c982239438 oid sha256:bd95a11b21ba3176f8f6d3e3286cc657de9537813739e0ae125e145eeda3531c
size 82994 size 82985
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:8128aece82c38468ca5d44dbe1602282ecdd8aa6db46ea8968aec359cf2ef0e9 oid sha256:c398c384e7b40da0880948bd1cd313557e6009aa45bfbba22a1b5d7fa5f9ae40
size 318628 size 318622
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:0e1627337bdb45fef3f3c3bfd07ff7198919c3d48c09123bd7956536efc43354 oid sha256:eb3b24027ab8df500b2413e051ade2f224979cce016246db8e84faf8149730b4
size 59468 size 59463
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:158acc42dea8232a7b8a24f373198f42ad00eb507c37cd7749344b06cdb7393f oid sha256:5d9b24eabfe1a1e9b20e073a54b502fe2dd931888bbdfc0f9e3f80daf47da086
size 340751 size 340654
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:a48e1672bc55f0d0c2b5f2345554e5e491f8dada688374accb9e4a63597290e3 oid sha256:c03292b2869766486a4fce17d7822ac7303d0fb1df4f13575f0177537823c3bb
size 337134 size 337145
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:850458aa89e4cadabe9bde5b89d131c1eed38077ee1fd9e04f82aa50cf7504b2 oid sha256:b90380fb1e7089bf7d47cab12667adbce4249b2ec78b4eb112f0b244cbe3d72e
size 339376 size 339386
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:c263006ebed5bbccef51df5439d62a377abc91f6882c1f38d8f63524a55fc968 oid sha256:b26642d6f01ae553147d66e347da12469ea642a1fa27f70ed802a703f27f54af
size 371053 size 370905
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:bb67c46c12b1593eea1f3bcf3c561daf1f4d208676a884f76b973735a81bc313 oid sha256:95554490a7d6babe6354bbdc311271b94e62f42176c923eb2afb443d12e768a1
size 315113 size 315109
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:bb67c46c12b1593eea1f3bcf3c561daf1f4d208676a884f76b973735a81bc313 oid sha256:95554490a7d6babe6354bbdc311271b94e62f42176c923eb2afb443d12e768a1
size 315113 size 315109