mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
Add developer option for clearing the application cache (#852)
* Add developer option for clearing the application cache * Tweaks following code review
This commit is contained in:
+13
-1
@@ -16,11 +16,23 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
enum DeveloperOptionsScreenCoordinatorAction {
|
||||
case clearCache
|
||||
}
|
||||
|
||||
final class DeveloperOptionsScreenCoordinator: CoordinatorProtocol {
|
||||
private let viewModel: DeveloperOptionsScreenViewModelProtocol
|
||||
private var viewModel: DeveloperOptionsScreenViewModelProtocol
|
||||
|
||||
var callback: ((DeveloperOptionsScreenCoordinatorAction) -> Void)?
|
||||
|
||||
init() {
|
||||
viewModel = DeveloperOptionsScreenViewModel()
|
||||
viewModel.callback = { [weak self] action in
|
||||
switch action {
|
||||
case .clearCache:
|
||||
self?.callback?(.clearCache)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func toPresentable() -> AnyView {
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
enum DeveloperOptionsScreenViewModelAction { }
|
||||
enum DeveloperOptionsScreenViewModelAction {
|
||||
case clearCache
|
||||
}
|
||||
|
||||
struct DeveloperOptionsScreenViewState: BindableState {
|
||||
var bindings: DeveloperOptionsScreenViewStateBindings
|
||||
@@ -34,4 +36,5 @@ enum DeveloperOptionsScreenViewAction {
|
||||
case changedStartChatFlowEnabled
|
||||
case changedStartChatUserSuggestionsEnabled
|
||||
case changedInvitesFlowEnabled
|
||||
case clearCache
|
||||
}
|
||||
|
||||
@@ -45,6 +45,8 @@ class DeveloperOptionsScreenViewModel: DeveloperOptionsScreenViewModelType, Deve
|
||||
ServiceLocator.shared.settings.startChatUserSuggestionsEnabled = state.bindings.startChatUserSuggestionsEnabled
|
||||
case .changedInvitesFlowEnabled:
|
||||
ServiceLocator.shared.settings.invitesFlowEnabled = state.bindings.invitesFlowEnabled
|
||||
case .clearCache:
|
||||
callback?(.clearCache)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,9 +59,16 @@ struct DeveloperOptionsScreen: View {
|
||||
Text("🥳")
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.buttonStyle(FormButtonStyle())
|
||||
}
|
||||
.formSectionStyle()
|
||||
|
||||
Section {
|
||||
Button(role: .destructive) {
|
||||
context.send(viewAction: .clearCache)
|
||||
} label: {
|
||||
Text("Clear cache")
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
}
|
||||
}
|
||||
.overlay(effectsView)
|
||||
.scrollContentBackground(.hidden)
|
||||
|
||||
@@ -26,6 +26,7 @@ struct SettingsScreenCoordinatorParameters {
|
||||
enum SettingsScreenCoordinatorAction {
|
||||
case dismiss
|
||||
case logout
|
||||
case clearCache
|
||||
}
|
||||
|
||||
final class SettingsScreenCoordinator: CoordinatorProtocol {
|
||||
@@ -114,6 +115,14 @@ final class SettingsScreenCoordinator: CoordinatorProtocol {
|
||||
|
||||
private func presentDeveloperOptions() {
|
||||
let coordinator = DeveloperOptionsScreenCoordinator()
|
||||
|
||||
coordinator.callback = { [weak self] action in
|
||||
switch action {
|
||||
case .clearCache:
|
||||
self?.callback?(.clearCache)
|
||||
}
|
||||
}
|
||||
|
||||
parameters.navigationStackCoordinator?.push(coordinator)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user