mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 19:44:05 +00:00
updated preview tests
This commit is contained in:
@@ -371,6 +371,13 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
|||||||
|
|
||||||
/// Perform any required migrations for the app to function correctly.
|
/// Perform any required migrations for the app to function correctly.
|
||||||
private func performMigrationsIfNecessary(from oldVersion: Version, to newVersion: Version) {
|
private func performMigrationsIfNecessary(from oldVersion: Version, to newVersion: Version) {
|
||||||
|
// Migration for the old `hideTimelineMedia` flag.
|
||||||
|
if let userDefaults = UserDefaults(suiteName: InfoPlistReader.main.appGroupIdentifier),
|
||||||
|
let hideTimelineMedia = userDefaults.value(forKey: "hideTimelineMedia") as? Bool {
|
||||||
|
appSettings.timelineMediaVisibility = hideTimelineMedia ? .never : .always
|
||||||
|
userDefaults.removeObject(forKey: "hideTimelineMedia")
|
||||||
|
}
|
||||||
|
|
||||||
guard oldVersion != newVersion else { return }
|
guard oldVersion != newVersion else { return }
|
||||||
|
|
||||||
MXLog.info("The app was upgraded from \(oldVersion) to \(newVersion)")
|
MXLog.info("The app was upgraded from \(oldVersion) to \(newVersion)")
|
||||||
|
|||||||
+11
-6
@@ -54,12 +54,9 @@ struct AdvancedSettingsScreen: View {
|
|||||||
|
|
||||||
private var timelineMediaSection: some View {
|
private var timelineMediaSection: some View {
|
||||||
Section {
|
Section {
|
||||||
ListRow(label: .plain(title: L10n.screenAdvancedSettingsShowMediaTimelineAlwaysShow),
|
ListRow(label: .plain(title: L10n.screenAdvancedSettingsShowMediaTimelineTitle),
|
||||||
kind: .selection(isSelected: context.timelineMediaVisibility == .always) { context.timelineMediaVisibility = .always })
|
kind: .inlinePicker(selection: $context.timelineMediaVisibility,
|
||||||
ListRow(label: .plain(title: L10n.screenAdvancedSettingsShowMediaTimelinePrivateRooms),
|
items: TimelineMediaVisibility.items))
|
||||||
kind: .selection(isSelected: context.timelineMediaVisibility == .privateOnly) { context.timelineMediaVisibility = .privateOnly })
|
|
||||||
ListRow(label: .plain(title: L10n.screenAdvancedSettingsShowMediaTimelineAlwaysHide),
|
|
||||||
kind: .selection(isSelected: context.timelineMediaVisibility == .never) { context.timelineMediaVisibility = .never })
|
|
||||||
} header: {
|
} header: {
|
||||||
Text(L10n.screenAdvancedSettingsShowMediaTimelineTitle)
|
Text(L10n.screenAdvancedSettingsShowMediaTimelineTitle)
|
||||||
.compoundListSectionHeader()
|
.compoundListSectionHeader()
|
||||||
@@ -94,3 +91,11 @@ struct AdvancedSettingsScreen_Previews: PreviewProvider, TestablePreview {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private extension TimelineMediaVisibility {
|
||||||
|
static var items: [(title: String, tag: TimelineMediaVisibility)] {
|
||||||
|
[(title: L10n.screenAdvancedSettingsShowMediaTimelineAlwaysShow, tag: .always),
|
||||||
|
(title: L10n.screenAdvancedSettingsShowMediaTimelinePrivateRooms, tag: .privateOnly),
|
||||||
|
(title: L10n.screenAdvancedSettingsShowMediaTimelineAlwaysHide, tag: .never)]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -528,18 +528,20 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
|
|||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
|
|
||||||
appSettings.$timelineMediaVisibility
|
appSettings.$timelineMediaVisibility
|
||||||
.combineLatest(roomProxy.infoPublisher
|
.removeDuplicates()
|
||||||
.map(\.isPublic)
|
.flatMap { [weak self] timelineMediaVisibility -> AnyPublisher<Bool, Never> in
|
||||||
.removeDuplicates()
|
|
||||||
.receive(on: DispatchQueue.main))
|
|
||||||
.map { timelineMediaVisibility, isPublic in
|
|
||||||
switch timelineMediaVisibility {
|
switch timelineMediaVisibility {
|
||||||
case .always:
|
case .always:
|
||||||
false
|
return Just(false).eraseToAnyPublisher()
|
||||||
case .privateOnly:
|
|
||||||
isPublic
|
|
||||||
case .never:
|
case .never:
|
||||||
true
|
return Just(true).eraseToAnyPublisher()
|
||||||
|
case .privateOnly:
|
||||||
|
guard let self else { return Just(false).eraseToAnyPublisher() }
|
||||||
|
return roomProxy.infoPublisher
|
||||||
|
.map(\.isPublic)
|
||||||
|
.removeDuplicates()
|
||||||
|
.receive(on: DispatchQueue.main)
|
||||||
|
.eraseToAnyPublisher()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.weakAssign(to: \.state.hideTimelineMedia, on: self)
|
.weakAssign(to: \.state.hideTimelineMedia, on: self)
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:56abc8e0527cef938e91400dcee94e42e175c6a16c004623ab449fbe73c6f128
|
oid sha256:29bea26c7a1777f0ba6143ca67cfb6a6798b0acb616727cf56a475740c1d6cf6
|
||||||
size 164157
|
size 184442
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:f43d6fd518a5e05fddc64d8a8202a156cb7281a75df14f5a34879af7ab8b1471
|
oid sha256:e0e5e3c93611270fbca8c195f19b882e04045c94d6db5ed78e59fcbeb5be690f
|
||||||
size 192479
|
size 217644
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:757b7bee819f1553d1470763a003da399c368ea722b29aef090b9bbf4095fb8f
|
oid sha256:0eba191d57ac01baf5a87adbb52c5b8493cca2c7ab8d1a10d5e905eb78b2ee32
|
||||||
size 114474
|
size 129615
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:b2bc7dc5754c2802ac9f7c2ea28e43cc9c50ccd2ddb4ff3c051437225707e604
|
oid sha256:74b86514beb0ce8b06cfbd3e3b015f2319ab6014a6fc6da8978fc19a111beced
|
||||||
size 163544
|
size 168748
|
||||||
|
|||||||
Reference in New Issue
Block a user