mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Dismiss room invite notifications when rejecting them from the home screen. (#4074)
This commit is contained in:
@@ -137,9 +137,10 @@ struct HomeScreen_Previews: PreviewProvider, TestablePreview {
|
||||
let userSession = UserSessionMock(.init(clientProxy: clientProxy))
|
||||
|
||||
return HomeScreenViewModel(userSession: userSession,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
notificationManager: NotificationManagerMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,9 +144,10 @@ struct HomeScreenEmptyStateView_Previews: PreviewProvider, TestablePreview {
|
||||
roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded([])))))))
|
||||
|
||||
return HomeScreenViewModel(userSession: userSession,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
notificationManager: NotificationManagerMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -155,38 +155,39 @@ struct HomeScreenInviteCell_Previews: PreviewProvider, TestablePreview {
|
||||
static var previews: some View {
|
||||
VStack(spacing: 0) {
|
||||
HomeScreenInviteCell(room: .dmInvite,
|
||||
context: viewModel().context, hideInviteAvatars: false)
|
||||
context: makeViewModel().context, hideInviteAvatars: false)
|
||||
|
||||
HomeScreenInviteCell(room: .dmInvite,
|
||||
context: viewModel().context, hideInviteAvatars: false)
|
||||
context: makeViewModel().context, hideInviteAvatars: false)
|
||||
|
||||
HomeScreenInviteCell(room: .roomInvite(),
|
||||
context: viewModel().context, hideInviteAvatars: false)
|
||||
context: makeViewModel().context, hideInviteAvatars: false)
|
||||
|
||||
HomeScreenInviteCell(room: .roomInvite(),
|
||||
context: viewModel().context, hideInviteAvatars: false)
|
||||
context: makeViewModel().context, hideInviteAvatars: false)
|
||||
|
||||
HomeScreenInviteCell(room: .roomInvite(alias: "#footest:somewhere.org", avatarURL: .mockMXCAvatar),
|
||||
context: viewModel().context, hideInviteAvatars: false)
|
||||
context: makeViewModel().context, hideInviteAvatars: false)
|
||||
HomeScreenInviteCell(room: .roomInvite(alias: "#footest-hidden-avatars:somewhere.org", avatarURL: .mockMXCAvatar),
|
||||
context: viewModel().context, hideInviteAvatars: true)
|
||||
context: makeViewModel().context, hideInviteAvatars: true)
|
||||
HomeScreenInviteCell(room: .roomInvite(alias: "#footest:somewhere.org"),
|
||||
context: viewModel().context, hideInviteAvatars: false)
|
||||
context: makeViewModel().context, hideInviteAvatars: false)
|
||||
.dynamicTypeSize(.accessibility1)
|
||||
.previewDisplayName("Aliased room (AX1)")
|
||||
}
|
||||
.previewLayout(.sizeThatFits)
|
||||
}
|
||||
|
||||
static func viewModel() -> HomeScreenViewModel {
|
||||
static func makeViewModel() -> HomeScreenViewModel {
|
||||
let clientProxy = ClientProxyMock(.init())
|
||||
|
||||
let userSession = UserSessionMock(.init(clientProxy: clientProxy))
|
||||
|
||||
return HomeScreenViewModel(userSession: userSession,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
notificationManager: NotificationManagerMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,37 +101,38 @@ struct HomeScreenKnockedCell_Previews: PreviewProvider, TestablePreview {
|
||||
ScrollView {
|
||||
VStack(spacing: 0) {
|
||||
HomeScreenKnockedCell(room: .dmInvite,
|
||||
context: viewModel().context)
|
||||
context: makeViewModel().context)
|
||||
|
||||
HomeScreenKnockedCell(room: .dmInvite,
|
||||
context: viewModel().context)
|
||||
context: makeViewModel().context)
|
||||
|
||||
HomeScreenKnockedCell(room: .roomKnocked(),
|
||||
context: viewModel().context)
|
||||
context: makeViewModel().context)
|
||||
|
||||
HomeScreenKnockedCell(room: .roomKnocked(),
|
||||
context: viewModel().context)
|
||||
context: makeViewModel().context)
|
||||
|
||||
HomeScreenKnockedCell(room: .roomKnocked(alias: "#footest:somewhere.org", avatarURL: .mockMXCAvatar),
|
||||
context: viewModel().context)
|
||||
context: makeViewModel().context)
|
||||
|
||||
HomeScreenKnockedCell(room: .roomKnocked(alias: "#footest:somewhere.org"),
|
||||
context: viewModel().context)
|
||||
context: makeViewModel().context)
|
||||
.dynamicTypeSize(.accessibility1)
|
||||
.previewDisplayName("Aliased room (AX1)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func viewModel() -> HomeScreenViewModel {
|
||||
static func makeViewModel() -> HomeScreenViewModel {
|
||||
let clientProxy = ClientProxyMock(.init())
|
||||
|
||||
let userSession = UserSessionMock(.init(clientProxy: clientProxy))
|
||||
|
||||
return HomeScreenViewModel(userSession: userSession,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
notificationManager: NotificationManagerMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
}
|
||||
}
|
||||
|
||||
+5
-4
@@ -103,7 +103,7 @@ struct HomeScreenRecoveryKeyConfirmationBanner: View {
|
||||
}
|
||||
|
||||
struct HomeScreenRecoveryKeyConfirmationBanner_Previews: PreviewProvider, TestablePreview {
|
||||
static let viewModel = buildViewModel()
|
||||
static let viewModel = makeViewModel()
|
||||
|
||||
static var previews: some View {
|
||||
HomeScreenRecoveryKeyConfirmationBanner(state: .setUpRecovery,
|
||||
@@ -114,16 +114,17 @@ struct HomeScreenRecoveryKeyConfirmationBanner_Previews: PreviewProvider, Testab
|
||||
.previewDisplayName("Out of sync")
|
||||
}
|
||||
|
||||
static func buildViewModel() -> HomeScreenViewModel {
|
||||
static func makeViewModel() -> HomeScreenViewModel {
|
||||
let clientProxy = ClientProxyMock(.init(userID: "@alice:example.com",
|
||||
roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loading))))
|
||||
|
||||
let userSession = UserSessionMock(.init(clientProxy: clientProxy))
|
||||
|
||||
return HomeScreenViewModel(userSession: userSession,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
notificationManager: NotificationManagerMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,36 +164,14 @@ private extension View {
|
||||
|
||||
struct HomeScreenRoomCell_Previews: PreviewProvider, TestablePreview {
|
||||
static let summaryProviderGeneric = RoomSummaryProviderMock(.init(state: .loaded(.mockRooms)))
|
||||
static let viewModelGeneric = {
|
||||
let userSession = UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userID: "John Doe", roomSummaryProvider: summaryProviderGeneric))))
|
||||
|
||||
return HomeScreenViewModel(userSession: userSession,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
}()
|
||||
static let viewModelGeneric = makeViewModel(roomSummaryProvider: summaryProviderGeneric)
|
||||
static let genericRooms = summaryProviderGeneric.roomListPublisher.value.compactMap(mockRoom)
|
||||
|
||||
static let summaryProviderForNotificationsState = RoomSummaryProviderMock(.init(state: .loaded(.mockRoomsWithNotificationsState)))
|
||||
static let viewModelForNotificationsState = {
|
||||
let userSession = UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userID: "John Doe", roomSummaryProvider: summaryProviderForNotificationsState))))
|
||||
|
||||
return HomeScreenViewModel(userSession: userSession,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
}()
|
||||
|
||||
static func mockRoom(summary: RoomSummary) -> HomeScreenRoom? {
|
||||
HomeScreenRoom(summary: summary, hideUnreadMessagesBadge: false)
|
||||
}
|
||||
static let viewModelForNotificationsState = makeViewModel(roomSummaryProvider: summaryProviderForNotificationsState)
|
||||
static let notificationsStateRooms = summaryProviderForNotificationsState.roomListPublisher.value.compactMap(mockRoom)
|
||||
|
||||
static var previews: some View {
|
||||
let genericRooms: [HomeScreenRoom] = summaryProviderGeneric.roomListPublisher.value.compactMap(mockRoom)
|
||||
|
||||
let notificationsStateRooms: [HomeScreenRoom] = summaryProviderForNotificationsState.roomListPublisher.value.compactMap(mockRoom)
|
||||
|
||||
VStack(spacing: 0) {
|
||||
ForEach(genericRooms) { room in
|
||||
HomeScreenRoomCell(room: room, context: viewModelGeneric.context, isSelected: false)
|
||||
@@ -212,4 +190,19 @@ struct HomeScreenRoomCell_Previews: PreviewProvider, TestablePreview {
|
||||
.previewLayout(.sizeThatFits)
|
||||
.previewDisplayName("Notifications State")
|
||||
}
|
||||
|
||||
static func mockRoom(summary: RoomSummary) -> HomeScreenRoom? {
|
||||
HomeScreenRoom(summary: summary, hideUnreadMessagesBadge: false)
|
||||
}
|
||||
|
||||
static func makeViewModel(roomSummaryProvider: RoomSummaryProviderProtocol) -> HomeScreenViewModel {
|
||||
let userSession = UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userID: "John Doe", roomSummaryProvider: roomSummaryProvider))))
|
||||
|
||||
return HomeScreenViewModel(userSession: userSession,
|
||||
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
notificationManager: NotificationManagerMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user