updated SDK and improved report flow

the report flow is now based on the matrix version and the new one will only be used if the SDK checks if the server supports it.
This commit is contained in:
Mauro Romito
2025-04-29 17:43:56 +02:00
committed by Mauro
parent cad21daeea
commit 0f53ad6724
17 changed files with 82 additions and 48 deletions
@@ -108,9 +108,9 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
.weakAssign(to: \.state.hideInviteAvatars, on: self)
.store(in: &cancellables)
appSettings.$reportRoomEnabled
.weakAssign(to: \.state.reportRoomEnabled, on: self)
.store(in: &cancellables)
Task {
state.reportRoomEnabled = await userSession.clientProxy.isReportRoomSupported
}
let isSearchFieldFocused = context.$viewState.map(\.bindings.isSearchFieldFocused)
let searchQuery = context.$viewState.map(\.bindings.searchQuery)
@@ -208,7 +208,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
await acceptInvite(roomID: roomIdentifier)
}
case .declineInvite(let roomIdentifier):
showDeclineInviteConfirmationAlert(roomID: roomIdentifier)
Task { await showDeclineInviteConfirmationAlert(roomID: roomIdentifier) }
}
}
@@ -419,7 +419,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
}
}
private func showDeclineInviteConfirmationAlert(roomID: String) {
private func showDeclineInviteConfirmationAlert(roomID: String) async {
guard let room = state.rooms.first(where: { $0.id == roomID }) else {
displayError()
return
@@ -429,7 +429,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
let title = room.isDirect ? L10n.screenInvitesDeclineDirectChatTitle : L10n.screenInvitesDeclineChatTitle
let message = room.isDirect ? L10n.screenInvitesDeclineDirectChatMessage(roomPlaceholder) : L10n.screenInvitesDeclineChatMessage(roomPlaceholder)
if appSettings.reportInviteEnabled, let userID = room.inviter?.id {
if await userSession.clientProxy.isReportRoomSupported, let userID = room.inviter?.id {
state.bindings.alertInfo = .init(id: UUID(),
title: title,
message: message,
@@ -83,7 +83,7 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
case .dismiss:
actionsSubject.send(.dismiss)
case .declineInviteAndBlock(let userID):
showDeclineAndBlockConfirmationAlert(userID: userID)
Task { await showDeclineAndBlockConfirmationAlert(userID: userID) }
}
}
@@ -322,8 +322,8 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
secondaryButton: .init(title: L10n.screenJoinRoomCancelKnockAlertConfirmation, role: .destructive) { Task { await self.cancelKnock() } })
}
private func showDeclineAndBlockConfirmationAlert(userID: String) {
if appSettings.reportInviteEnabled {
private func showDeclineAndBlockConfirmationAlert(userID: String) async {
if await clientProxy.isReportRoomSupported {
actionsSubject.send(.presentDeclineAndBlock(userID: userID))
} else {
state.bindings.alertInfo = .init(id: .declineInviteAndBlock,
@@ -78,9 +78,9 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
.weakAssign(to: \.state.knockingEnabled, on: self)
.store(in: &cancellables)
appSettings.$reportRoomEnabled
.weakAssign(to: \.state.reportRoomEnabled, on: self)
.store(in: &cancellables)
Task {
state.reportRoomEnabled = await clientProxy.isReportRoomSupported
}
appMediator.networkMonitor.reachabilityPublisher
.filter { $0 == .reachable }
@@ -44,8 +44,6 @@ protocol DeveloperOptionsProtocol: AnyObject {
var enableOnlySignedDeviceIsolationMode: Bool { get set }
var elementCallBaseURLOverride: URL? { get set }
var knockingEnabled: Bool { get set }
var reportRoomEnabled: Bool { get set }
var reportInviteEnabled: Bool { get set }
var threadsEnabled: Bool { get set }
var isNewBloomEnabled: Bool { get set }
}
@@ -73,17 +73,6 @@ struct DeveloperOptionsScreen: View {
} footer: {
Text("This setting controls how end-to-end encryption (E2EE) keys are exchanged. Enabling it will prevent the inclusion of devices that have not been explicitly verified by their owners.")
}
Section("Reporting") {
Toggle(isOn: $context.reportRoomEnabled) {
Text("Report rooms")
Text("Report API might not work properly")
}
Toggle(isOn: $context.reportInviteEnabled) {
Text("Report invites")
Text("Report API might not work properly")
}
}
Section {
TextField("Leave empty to use EC locally", text: $elementCallURLOverrideString)