mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Add a developer option button for marking every single room as read (#5582)
This will use an underlying SDK method and send a private read receipt plus a fully read marker in every single room the user is part of. It will most likely be a long operation that will get rate limited so the task is set to run detached for as long as it takes.
This commit is contained in:
+1
@@ -48,6 +48,7 @@ struct DeveloperOptionsScreenViewStateBindings {
|
||||
|
||||
enum DeveloperOptionsScreenViewAction {
|
||||
case clearCache
|
||||
case markAllRoomsAsRead
|
||||
}
|
||||
|
||||
protocol DeveloperOptionsProtocol: AnyObject {
|
||||
|
||||
+7
@@ -18,7 +18,10 @@ class DeveloperOptionsScreenViewModel: DeveloperOptionsScreenViewModelType, Deve
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
private let clientProxy: ClientProxyProtocol?
|
||||
|
||||
init(developerOptions: DeveloperOptionsProtocol, elementCallBaseURL: URL, appHooks: AppHooks, clientProxy: ClientProxyProtocol?) {
|
||||
self.clientProxy = clientProxy
|
||||
super.init(initialViewState: .init(elementCallBaseURL: elementCallBaseURL,
|
||||
appHooks: appHooks,
|
||||
shouldShowClearCache: clientProxy != nil,
|
||||
@@ -55,6 +58,10 @@ class DeveloperOptionsScreenViewModel: DeveloperOptionsScreenViewModelType, Deve
|
||||
switch viewAction {
|
||||
case .clearCache:
|
||||
actionsSubject.send(.clearCache)
|
||||
case .markAllRoomsAsRead:
|
||||
Task.detached {
|
||||
await self.clientProxy?.markAllRoomsAsRead()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+21
@@ -10,6 +10,7 @@ import SwiftUI
|
||||
|
||||
struct DeveloperOptionsScreen: View {
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@State private var showMarkAllRoomsAsReadAlert = false
|
||||
|
||||
@Bindable var context: DeveloperOptionsScreenViewModel.Context
|
||||
|
||||
@@ -130,6 +131,26 @@ struct DeveloperOptionsScreen: View {
|
||||
}
|
||||
}
|
||||
|
||||
Section {
|
||||
Button {
|
||||
showMarkAllRoomsAsReadAlert = true
|
||||
} label: {
|
||||
Text("Mark all rooms as read")
|
||||
}.alert("Are you sure you want to mark all the rooms as read?", isPresented: $showMarkAllRoomsAsReadAlert) {
|
||||
Button("Cancel", role: .cancel) { }
|
||||
|
||||
Button("Yes") {
|
||||
context.send(viewAction: .markAllRoomsAsRead)
|
||||
}
|
||||
}
|
||||
} footer: {
|
||||
Text("""
|
||||
This will send a private read receipt and a read marker in every room you are part of. \
|
||||
It's a long running operation that might get rate limited. \
|
||||
It will run in the background but the app must be alive for it to finish.
|
||||
""")
|
||||
}
|
||||
|
||||
Section {
|
||||
Button {
|
||||
showConfetti = true
|
||||
|
||||
Reference in New Issue
Block a user