feat: report a room

updated tests

updated tests

added a feature flag to report room

removed delay

rename
This commit is contained in:
Mauro Romito
2025-04-02 17:44:24 +02:00
committed by Mauro
parent 8149107aef
commit 2ee5c1b403
31 changed files with 750 additions and 104 deletions
@@ -17,6 +17,7 @@ struct HomeScreenCoordinatorParameters {
enum HomeScreenCoordinatorAction {
case presentRoom(roomIdentifier: String)
case presentRoomDetails(roomIdentifier: String)
case presentReportRoom(roomIdentifier: String)
case roomLeft(roomIdentifier: String)
case presentSettingsScreen
case presentFeedbackScreen
@@ -58,6 +59,8 @@ final class HomeScreenCoordinator: CoordinatorProtocol {
actionsSubject.send(.presentRoom(roomIdentifier: roomIdentifier))
case .presentRoomDetails(roomIdentifier: let roomIdentifier):
actionsSubject.send(.presentRoomDetails(roomIdentifier: roomIdentifier))
case .presentReportRoom(let roomIdentifier):
actionsSubject.send(.presentReportRoom(roomIdentifier: roomIdentifier))
case .roomLeft(roomIdentifier: let roomIdentifier):
actionsSubject.send(.roomLeft(roomIdentifier: roomIdentifier))
case .presentFeedbackScreen:
@@ -12,6 +12,7 @@ import UIKit
enum HomeScreenViewModelAction: Equatable {
case presentRoom(roomIdentifier: String)
case presentRoomDetails(roomIdentifier: String)
case presentReportRoom(roomIdentifier: String)
case roomLeft(roomIdentifier: String)
case presentSecureBackupSettings
case presentRecoveryKeyScreen
@@ -29,6 +30,7 @@ enum HomeScreenViewAction {
case showRoomDetails(roomIdentifier: String)
case leaveRoom(roomIdentifier: String)
case confirmLeaveRoom(roomIdentifier: String)
case reportRoom(roomIdentifier: String)
case showSettings
case startChat
case setupRecovery
@@ -98,6 +100,10 @@ struct HomeScreenViewState: BindableState {
var selectedRoomID: String?
var hideInviteAvatars = false
var reportRoomEnabled = false
var visibleRooms: [HomeScreenRoom] {
if roomListMode == .skeletons {
return placeholderRooms
@@ -105,9 +111,7 @@ struct HomeScreenViewState: BindableState {
return rooms
}
var hideInviteAvatars = false
var bindings = HomeScreenViewStateBindings()
var placeholderRooms: [HomeScreenRoom] {
@@ -105,6 +105,10 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
.weakAssign(to: \.state.hideInviteAvatars, on: self)
.store(in: &cancellables)
appSettings.$reportRoomEnabled
.weakAssign(to: \.state.reportRoomEnabled, on: self)
.store(in: &cancellables)
let isSearchFieldFocused = context.$viewState.map(\.bindings.isSearchFieldFocused)
let searchQuery = context.$viewState.map(\.bindings.searchQuery)
let activeFilters = context.$viewState.map(\.bindings.filtersState.activeFilters)
@@ -136,12 +140,14 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
switch viewAction {
case .selectRoom(let roomIdentifier):
actionsSubject.send(.presentRoom(roomIdentifier: roomIdentifier))
case .showRoomDetails(roomIdentifier: let roomIdentifier):
case .showRoomDetails(let roomIdentifier):
actionsSubject.send(.presentRoomDetails(roomIdentifier: roomIdentifier))
case .leaveRoom(roomIdentifier: let roomIdentifier):
case .leaveRoom(let roomIdentifier):
startLeaveRoomProcess(roomID: roomIdentifier)
case .confirmLeaveRoom(roomIdentifier: let roomIdentifier):
case .confirmLeaveRoom(let roomIdentifier):
Task { await leaveRoom(roomID: roomIdentifier) }
case .reportRoom(let roomIdentifier):
actionsSubject.send(.presentReportRoom(roomIdentifier: roomIdentifier))
case .showSettings:
actionsSubject.send(.presentSettingsScreen)
case .setupRecovery:
@@ -69,6 +69,14 @@ struct HomeScreenRoomList: View {
Label(L10n.commonSettings, icon: \.settings)
}
if context.viewState.reportRoomEnabled {
Button(role: .destructive) {
context.send(viewAction: .reportRoom(roomIdentifier: room.id))
} label: {
Label(L10n.actionReportRoom, icon: \.chatProblem)
}
}
Button(role: .destructive) {
context.send(viewAction: .leaveRoom(roomIdentifier: room.id))
} label: {