mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-11 13:59:13 +00:00
Display whether a call is ongoing in any particular room on the room list
This commit is contained in:
parent
2e1b4cb80b
commit
5c4e0bd76d
@ -1861,11 +1861,11 @@ class RoomProxyMock: RoomProxyProtocol {
|
||||
set(value) { underlyingIsTombstoned = value }
|
||||
}
|
||||
var underlyingIsTombstoned: Bool!
|
||||
var isCallOngoing: Bool {
|
||||
get { return underlyingIsCallOngoing }
|
||||
set(value) { underlyingIsCallOngoing = value }
|
||||
var hasOngoingCall: Bool {
|
||||
get { return underlyingHasOngoingCall }
|
||||
set(value) { underlyingHasOngoingCall = value }
|
||||
}
|
||||
var underlyingIsCallOngoing: Bool!
|
||||
var underlyingHasOngoingCall: Bool!
|
||||
var canonicalAlias: String?
|
||||
var alternativeAliases: [String] = []
|
||||
var hasUnreadNotifications: Bool {
|
||||
|
@ -28,7 +28,7 @@ struct RoomProxyMockConfiguration {
|
||||
var isPublic = Bool.random()
|
||||
var isEncrypted = Bool.random()
|
||||
var isTombstoned = Bool.random()
|
||||
var isCallOngoing = false
|
||||
var hasOngoingCall = false
|
||||
var canonicalAlias: String?
|
||||
var alternativeAliases: [String] = []
|
||||
var hasUnreadNotifications = Bool.random()
|
||||
@ -57,7 +57,7 @@ extension RoomProxyMock {
|
||||
isPublic = configuration.isPublic
|
||||
isEncrypted = configuration.isEncrypted
|
||||
isTombstoned = configuration.isTombstoned
|
||||
isCallOngoing = configuration.isCallOngoing
|
||||
hasOngoingCall = configuration.hasOngoingCall
|
||||
canonicalAlias = configuration.canonicalAlias
|
||||
alternativeAliases = configuration.alternativeAliases
|
||||
hasUnreadNotifications = configuration.hasUnreadNotifications
|
||||
|
@ -124,6 +124,8 @@ struct HomeScreenRoom: Identifiable, Equatable {
|
||||
|
||||
var hasUnreads = false
|
||||
|
||||
var hasOngoingCall = false
|
||||
|
||||
var timestamp: String?
|
||||
|
||||
var lastMessage: AttributedString?
|
||||
@ -132,12 +134,6 @@ struct HomeScreenRoom: Identifiable, Equatable {
|
||||
|
||||
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
|
||||
|
||||
static func placeholder() -> HomeScreenRoom {
|
||||
|
@ -311,6 +311,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
roomId: details.id,
|
||||
name: details.name,
|
||||
hasUnreads: details.unreadNotificationCount > 0,
|
||||
hasOngoingCall: details.hasOngoingCall,
|
||||
timestamp: details.lastMessageFormattedTimestamp,
|
||||
lastMessage: details.lastMessage,
|
||||
avatarURL: details.avatarURL,
|
||||
|
@ -117,6 +117,11 @@ struct HomeScreenRoomCell: View {
|
||||
Spacer()
|
||||
|
||||
HStack(spacing: 8) {
|
||||
if room.hasOngoingCall {
|
||||
CompoundIcon(\.videoCallSolid, size: .xSmall, relativeTo: .compound.bodySM)
|
||||
.foregroundColor(room.hasUnreads ? .compound.iconAccentTertiary : .compound.iconQuaternary)
|
||||
}
|
||||
|
||||
notificationModeIcon
|
||||
.foregroundColor(room.hasUnreads ? .compound.iconAccentTertiary : .compound.iconQuaternary)
|
||||
|
||||
@ -125,16 +130,8 @@ struct HomeScreenRoomCell: View {
|
||||
.frame(width: 12, height: 12)
|
||||
.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)
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
@ -205,6 +202,7 @@ struct HomeScreenRoomCell_Previews: PreviewProvider, TestablePreview {
|
||||
roomId: details.id,
|
||||
name: details.name,
|
||||
hasUnreads: details.unreadNotificationCount > 0,
|
||||
hasOngoingCall: details.hasOngoingCall,
|
||||
timestamp: Date(timeIntervalSinceReferenceDate: 0).formattedMinimal(),
|
||||
lastMessage: details.lastMessage,
|
||||
notificationMode: details.notificationMode)
|
||||
|
@ -191,7 +191,8 @@ private extension InvitesScreenRoomDetails {
|
||||
unreadNotificationCount: 0,
|
||||
notificationMode: nil,
|
||||
canonicalAlias: "#footest:somewhere.org",
|
||||
inviter: inviter)
|
||||
inviter: inviter,
|
||||
hasOngoingCall: false)
|
||||
return .init(roomDetails: dmRoom, isUnread: false)
|
||||
}
|
||||
|
||||
@ -210,7 +211,8 @@ private extension InvitesScreenRoomDetails {
|
||||
unreadNotificationCount: 0,
|
||||
notificationMode: nil,
|
||||
canonicalAlias: alias,
|
||||
inviter: inviter)
|
||||
inviter: inviter,
|
||||
hasOngoingCall: false)
|
||||
return .init(roomDetails: dmRoom, isUnread: isUnread)
|
||||
}
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ struct RoomScreenViewState: BindableState {
|
||||
|
||||
var ownUserID: String
|
||||
|
||||
var isCallOngoing = false
|
||||
var hasOngoingCall = false
|
||||
|
||||
var bindings: RoomScreenViewStateBindings
|
||||
|
||||
|
@ -87,7 +87,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
readReceiptsEnabled: appSettings.readReceiptsEnabled,
|
||||
isEncryptedOneToOneRoom: roomProxy.isEncryptedOneToOneRoom,
|
||||
ownUserID: roomProxy.ownUserID,
|
||||
isCallOngoing: roomProxy.isCallOngoing,
|
||||
hasOngoingCall: roomProxy.hasOngoingCall,
|
||||
bindings: .init(reactionsCollapsed: [:])),
|
||||
imageProvider: mediaProvider)
|
||||
|
||||
@ -281,7 +281,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
guard let self else { return }
|
||||
self.state.roomTitle = roomProxy.roomTitle
|
||||
self.state.roomAvatarURL = roomProxy.avatarURL
|
||||
self.state.isCallOngoing = roomProxy.isCallOngoing
|
||||
self.state.hasOngoingCall = roomProxy.hasOngoingCall
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
|
@ -164,7 +164,7 @@ struct RoomScreen: View {
|
||||
|
||||
@ViewBuilder
|
||||
private var callButton: some View {
|
||||
if context.viewState.isCallOngoing {
|
||||
if context.viewState.hasOngoingCall {
|
||||
Button {
|
||||
context.send(viewAction: .presentCall)
|
||||
} label: {
|
||||
@ -189,7 +189,7 @@ struct RoomScreen: View {
|
||||
// MARK: - Previews
|
||||
|
||||
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(),
|
||||
mediaProvider: MockMediaProvider(),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
|
@ -24,6 +24,7 @@ struct SeparatorRoomTimelineView: View {
|
||||
.font(.compound.bodySMSemibold)
|
||||
.foregroundColor(.compound.textPrimary)
|
||||
.frame(maxWidth: .infinity)
|
||||
.multilineTextAlignment(.center)
|
||||
.padding(.horizontal, 36.0)
|
||||
.padding(.vertical, 8.0)
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ class RoomProxy: RoomProxyProtocol {
|
||||
room.isTombstoned()
|
||||
}
|
||||
|
||||
var isCallOngoing: Bool {
|
||||
var hasOngoingCall: Bool {
|
||||
room.hasActiveRoomCall()
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ protocol RoomProxyProtocol {
|
||||
var isSpace: Bool { get }
|
||||
var isEncrypted: Bool { get }
|
||||
var isTombstoned: Bool { get }
|
||||
var isCallOngoing: Bool { get }
|
||||
var hasOngoingCall: Bool { get }
|
||||
var canonicalAlias: String? { get }
|
||||
var alternativeAliases: [String] { get }
|
||||
var hasUnreadNotifications: Bool { get }
|
||||
|
@ -85,7 +85,8 @@ extension Array where Element == RoomSummary {
|
||||
unreadNotificationCount: 4,
|
||||
notificationMode: .allMessages,
|
||||
canonicalAlias: nil,
|
||||
inviter: RoomMemberProxyMock.mockCharlie)),
|
||||
inviter: RoomMemberProxyMock.mockCharlie,
|
||||
hasOngoingCall: true)),
|
||||
.filled(details: RoomSummaryDetails(id: "2",
|
||||
name: "Second room",
|
||||
isDirect: true,
|
||||
@ -95,7 +96,8 @@ extension Array where Element == RoomSummary {
|
||||
unreadNotificationCount: 1,
|
||||
notificationMode: .mentionsAndKeywordsOnly,
|
||||
canonicalAlias: nil,
|
||||
inviter: RoomMemberProxyMock.mockCharlie)),
|
||||
inviter: RoomMemberProxyMock.mockCharlie,
|
||||
hasOngoingCall: false)),
|
||||
.filled(details: RoomSummaryDetails(id: "3",
|
||||
name: "Third room",
|
||||
isDirect: true,
|
||||
@ -105,7 +107,8 @@ extension Array where Element == RoomSummary {
|
||||
unreadNotificationCount: 0,
|
||||
notificationMode: .mute,
|
||||
canonicalAlias: nil,
|
||||
inviter: RoomMemberProxyMock.mockCharlie)),
|
||||
inviter: RoomMemberProxyMock.mockCharlie,
|
||||
hasOngoingCall: false)),
|
||||
.empty
|
||||
]
|
||||
|
||||
@ -118,7 +121,8 @@ extension Array where Element == RoomSummary {
|
||||
unreadNotificationCount: 0,
|
||||
notificationMode: nil,
|
||||
canonicalAlias: "#footest:somewhere.org",
|
||||
inviter: RoomMemberProxyMock.mockCharlie)),
|
||||
inviter: RoomMemberProxyMock.mockCharlie,
|
||||
hasOngoingCall: false)),
|
||||
.filled(details: RoomSummaryDetails(id: "someAwesomeRoomId2",
|
||||
name: "Second room",
|
||||
isDirect: true,
|
||||
@ -128,6 +132,7 @@ extension Array where Element == RoomSummary {
|
||||
unreadNotificationCount: 0,
|
||||
notificationMode: nil,
|
||||
canonicalAlias: nil,
|
||||
inviter: RoomMemberProxyMock.mockCharlie))
|
||||
inviter: RoomMemberProxyMock.mockCharlie,
|
||||
hasOngoingCall: false))
|
||||
]
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ struct RoomSummaryDetails {
|
||||
let notificationMode: RoomNotificationModeProxy?
|
||||
let canonicalAlias: String?
|
||||
let inviter: RoomMemberProxyProtocol?
|
||||
let hasOngoingCall: Bool
|
||||
}
|
||||
|
||||
extension RoomSummaryDetails: CustomStringConvertible {
|
||||
|
@ -248,7 +248,8 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
|
||||
unreadNotificationCount: UInt(roomInfo.notificationCount),
|
||||
notificationMode: notificationMode,
|
||||
canonicalAlias: roomInfo.canonicalAlias,
|
||||
inviter: inviterProxy)
|
||||
inviter: inviterProxy,
|
||||
hasOngoingCall: roomInfo.hasRoomCall)
|
||||
|
||||
return invalidated ? .invalidated(details: details) : .filled(details: details)
|
||||
}
|
||||
|
@ -232,7 +232,8 @@ class LoggingTests: XCTestCase {
|
||||
unreadNotificationCount: 0,
|
||||
notificationMode: nil,
|
||||
canonicalAlias: nil,
|
||||
inviter: nil)
|
||||
inviter: nil,
|
||||
hasOngoingCall: false)
|
||||
|
||||
// When logging that value
|
||||
XCTAssert(MXLogger.logFiles.isEmpty)
|
||||
|
BIN
UnitTests/__Snapshots__/PreviewTests/test_homeScreen.Loaded.png
(Stored with Git LFS)
BIN
UnitTests/__Snapshots__/PreviewTests/test_homeScreen.Loaded.png
(Stored with Git LFS)
Binary file not shown.
BIN
UnitTests/__Snapshots__/PreviewTests/test_homeScreenRoomCell.1.png
(Stored with Git LFS)
BIN
UnitTests/__Snapshots__/PreviewTests/test_homeScreenRoomCell.1.png
(Stored with Git LFS)
Binary file not shown.
BIN
UnitTests/__Snapshots__/PreviewTests/test_mediaUploadPreviewScreen.1.png
(Stored with Git LFS)
BIN
UnitTests/__Snapshots__/PreviewTests/test_mediaUploadPreviewScreen.1.png
(Stored with Git LFS)
Binary file not shown.
BIN
UnitTests/__Snapshots__/PreviewTests/test_readMarkerRoomTimelineView.1.png
(Stored with Git LFS)
BIN
UnitTests/__Snapshots__/PreviewTests/test_readMarkerRoomTimelineView.1.png
(Stored with Git LFS)
Binary file not shown.
BIN
UnitTests/__Snapshots__/PreviewTests/test_roomScreen.1.png
(Stored with Git LFS)
BIN
UnitTests/__Snapshots__/PreviewTests/test_roomScreen.1.png
(Stored with Git LFS)
Binary file not shown.
BIN
UnitTests/__Snapshots__/PreviewTests/test_separatorRoomTimelineView.1.png
(Stored with Git LFS)
BIN
UnitTests/__Snapshots__/PreviewTests/test_separatorRoomTimelineView.1.png
(Stored with Git LFS)
Binary file not shown.
BIN
UnitTests/__Snapshots__/PreviewTests/test_timelineItemBubbledStylerView.Mock-Timeline-RTL.png
(Stored with Git LFS)
BIN
UnitTests/__Snapshots__/PreviewTests/test_timelineItemBubbledStylerView.Mock-Timeline-RTL.png
(Stored with Git LFS)
Binary file not shown.
Binary file not shown.
BIN
UnitTests/__Snapshots__/PreviewTests/test_timelineItemBubbledStylerView.Mock-Timeline.png
(Stored with Git LFS)
BIN
UnitTests/__Snapshots__/PreviewTests/test_timelineItemBubbledStylerView.Mock-Timeline.png
(Stored with Git LFS)
Binary file not shown.
BIN
UnitTests/__Snapshots__/PreviewTests/test_timelineItemPlainStylerView.1.png
(Stored with Git LFS)
BIN
UnitTests/__Snapshots__/PreviewTests/test_timelineItemPlainStylerView.1.png
(Stored with Git LFS)
Binary file not shown.
BIN
UnitTests/__Snapshots__/PreviewTests/test_timelineView.1.png
(Stored with Git LFS)
BIN
UnitTests/__Snapshots__/PreviewTests/test_timelineView.1.png
(Stored with Git LFS)
Binary file not shown.
BIN
UnitTests/__Snapshots__/PreviewTests/test_uITimelineView.1.png
(Stored with Git LFS)
BIN
UnitTests/__Snapshots__/PreviewTests/test_uITimelineView.1.png
(Stored with Git LFS)
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user