mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Clear cache on changing the threads FF (#4581)
* clear cache on changing the threads FF # Conflicts: # PreviewTests/Sources/__Snapshots__/PreviewTests/labsScreen.iPad-pseudo-0.png # PreviewTests/Sources/__Snapshots__/PreviewTests/labsScreen.iPhone-16-pseudo-0.png * fix tests
This commit is contained in:
@@ -117,6 +117,15 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol {
|
||||
|
||||
private func presentLabs() {
|
||||
let coordinator = LabsScreenCoordinator(parameters: .init(appSettings: flowParameters.appSettings))
|
||||
coordinator.actions
|
||||
.sink { [weak self] action in
|
||||
switch action {
|
||||
case .clearCache:
|
||||
self?.actionsSubject.send(.clearCache)
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
navigationStackCoordinator.push(coordinator)
|
||||
}
|
||||
|
||||
|
||||
@@ -662,6 +662,8 @@ internal enum L10n {
|
||||
internal static var commonShareSpace: String { return L10n.tr("Localizable", "common_share_space") }
|
||||
/// Shared location
|
||||
internal static var commonSharedLocation: String { return L10n.tr("Localizable", "common_shared_location") }
|
||||
/// Shared space
|
||||
internal static var commonSharedSpace: String { return L10n.tr("Localizable", "common_shared_space") }
|
||||
/// Signing out
|
||||
internal static var commonSigningOut: String { return L10n.tr("Localizable", "common_signing_out") }
|
||||
/// Something went wrong
|
||||
@@ -1682,11 +1684,11 @@ internal enum L10n {
|
||||
internal static func screenInvitesInvitedYou(_ p1: Any, _ p2: Any) -> String {
|
||||
return L10n.tr("Localizable", "screen_invites_invited_you", String(describing: p1), String(describing: p2))
|
||||
}
|
||||
/// You were banned from this room by %1$@.
|
||||
/// You were banned by %1$@.
|
||||
internal static func screenJoinRoomBanByMessage(_ p1: Any) -> String {
|
||||
return L10n.tr("Localizable", "screen_join_room_ban_by_message", String(describing: p1))
|
||||
}
|
||||
/// You were banned from this room
|
||||
/// You were banned
|
||||
internal static var screenJoinRoomBanMessage: String { return L10n.tr("Localizable", "screen_join_room_ban_message") }
|
||||
/// Reason: %1$@.
|
||||
internal static func screenJoinRoomBanReason(_ p1: Any) -> String {
|
||||
@@ -1710,17 +1712,17 @@ internal enum L10n {
|
||||
internal static var screenJoinRoomDeclineAndBlockAlertTitle: String { return L10n.tr("Localizable", "screen_join_room_decline_and_block_alert_title") }
|
||||
/// Decline and block
|
||||
internal static var screenJoinRoomDeclineAndBlockButtonTitle: String { return L10n.tr("Localizable", "screen_join_room_decline_and_block_button_title") }
|
||||
/// Joining the room failed.
|
||||
/// Joining failed
|
||||
internal static var screenJoinRoomFailMessage: String { return L10n.tr("Localizable", "screen_join_room_fail_message") }
|
||||
/// This room is either invite-only or there might be restrictions to access at space level.
|
||||
internal static var screenJoinRoomFailReason: String { return L10n.tr("Localizable", "screen_join_room_fail_reason") }
|
||||
/// Forget this room
|
||||
/// Forget
|
||||
internal static var screenJoinRoomForgetAction: String { return L10n.tr("Localizable", "screen_join_room_forget_action") }
|
||||
/// You need an invite in order to join this room
|
||||
/// You need an invite in order to join
|
||||
internal static var screenJoinRoomInviteRequiredMessage: String { return L10n.tr("Localizable", "screen_join_room_invite_required_message") }
|
||||
/// Invited by
|
||||
internal static var screenJoinRoomInvitedBy: String { return L10n.tr("Localizable", "screen_join_room_invited_by") }
|
||||
/// Join room
|
||||
/// Join
|
||||
internal static var screenJoinRoomJoinAction: String { return L10n.tr("Localizable", "screen_join_room_join_action") }
|
||||
/// You may need to be invited or be a member of a space in order to join.
|
||||
internal static var screenJoinRoomJoinRestrictedMessage: String { return L10n.tr("Localizable", "screen_join_room_join_restricted_message") }
|
||||
@@ -1826,6 +1828,8 @@ internal enum L10n {
|
||||
internal static var screenKnockRequestsListTitle: String { return L10n.tr("Localizable", "screen_knock_requests_list_title") }
|
||||
/// Enable thread replies
|
||||
internal static var screenLabsEnableThreads: String { return L10n.tr("Localizable", "screen_labs_enable_threads") }
|
||||
/// The app will restart to apply this change.
|
||||
internal static var screenLabsEnableThreadsDescription: String { return L10n.tr("Localizable", "screen_labs_enable_threads_description") }
|
||||
/// Try out our latest ideas in development. These features are not finalised; they may be unstable, may change.
|
||||
internal static var screenLabsHeaderDescription: String { return L10n.tr("Localizable", "screen_labs_header_description") }
|
||||
/// Feeling experimental?
|
||||
|
||||
@@ -14,14 +14,35 @@ struct LabsScreenCoordinatorParameters {
|
||||
let appSettings: AppSettings
|
||||
}
|
||||
|
||||
enum LabsScreenCoordinatorAction {
|
||||
case clearCache
|
||||
}
|
||||
|
||||
final class LabsScreenCoordinator: CoordinatorProtocol {
|
||||
private let viewModel: LabsScreenViewModelProtocol
|
||||
|
||||
private let actionsSubject: PassthroughSubject<LabsScreenCoordinatorAction, Never> = .init()
|
||||
var actions: AnyPublisher<LabsScreenCoordinatorAction, Never> {
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
|
||||
init(parameters: LabsScreenCoordinatorParameters) {
|
||||
viewModel = LabsScreenViewModel(labsOptions: parameters.appSettings)
|
||||
}
|
||||
|
||||
func start() { }
|
||||
func start() {
|
||||
viewModel
|
||||
.actionsPublisher
|
||||
.sink { [weak self] action in
|
||||
switch action {
|
||||
case .clearCache:
|
||||
self?.actionsSubject.send(.clearCache)
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
func toPresentable() -> AnyView {
|
||||
AnyView(LabsScreen(context: viewModel.context))
|
||||
|
||||
@@ -7,9 +7,13 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
enum LabsScreenViewAction { }
|
||||
enum LabsScreenViewAction {
|
||||
case clearCache
|
||||
}
|
||||
|
||||
enum LabsScreenViewModelAction { }
|
||||
enum LabsScreenViewModelAction {
|
||||
case clearCache
|
||||
}
|
||||
|
||||
struct LabsScreenViewState: BindableState {
|
||||
var bindings: LabsScreenViewStateBindings
|
||||
|
||||
@@ -22,4 +22,11 @@ class LabsScreenViewModel: LabsScreenViewModelType, LabsScreenViewModelProtocol
|
||||
|
||||
super.init(initialViewState: state)
|
||||
}
|
||||
|
||||
override func process(viewAction: LabsScreenViewAction) {
|
||||
switch viewAction {
|
||||
case .clearCache:
|
||||
actionsSubject.send(.clearCache)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ struct LabsScreen: View {
|
||||
var body: some View {
|
||||
Form {
|
||||
header
|
||||
settingsSection
|
||||
threadsSection
|
||||
}
|
||||
.compoundList()
|
||||
.navigationTitle(L10n.screenLabsTitle)
|
||||
@@ -39,16 +39,23 @@ struct LabsScreen: View {
|
||||
.multilineTextAlignment(.center)
|
||||
.foregroundColor(.compound.textSecondary)
|
||||
}
|
||||
.compoundListSectionHeader()
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
}
|
||||
|
||||
private var settingsSection: some View {
|
||||
private var threadsSection: some View {
|
||||
Section {
|
||||
ListRow(label: .default(title: L10n.screenLabsEnableThreads,
|
||||
icon: \.threads),
|
||||
kind: .toggle($context.threadsEnabled))
|
||||
} footer: {
|
||||
Text(L10n.screenLabsEnableThreadsDescription)
|
||||
.compoundListSectionFooter()
|
||||
}
|
||||
.onChange(of: context.threadsEnabled) { _, _ in
|
||||
context.send(viewAction: .clearCache)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,7 +63,7 @@ struct LabsScreen: View {
|
||||
// MARK: - Previews
|
||||
|
||||
struct LabsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
static let viewModel = LabsScreenViewModel(labsOptions: ServiceLocator.shared.settings)
|
||||
static let viewModel = LabsScreenViewModel(labsOptions: AppSettings())
|
||||
|
||||
static var previews: some View {
|
||||
NavigationStack {
|
||||
|
||||
Reference in New Issue
Block a user