mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
avoid problems
This commit is contained in:
@@ -34,7 +34,6 @@ final class AppSettings {
|
|||||||
case readReceiptsEnabled
|
case readReceiptsEnabled
|
||||||
case hasShownWelcomeScreen
|
case hasShownWelcomeScreen
|
||||||
case notificationSettingsEnabled
|
case notificationSettingsEnabled
|
||||||
case timelineDiffableAnimationsEnabled
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static var suiteName: String = InfoPlistReader.main.appGroupIdentifier
|
private static var suiteName: String = InfoPlistReader.main.appGroupIdentifier
|
||||||
@@ -218,7 +217,4 @@ final class AppSettings {
|
|||||||
|
|
||||||
@UserPreference(key: UserDefaultsKeys.notificationSettingsEnabled, defaultValue: false, storageType: .userDefaults(store))
|
@UserPreference(key: UserDefaultsKeys.notificationSettingsEnabled, defaultValue: false, storageType: .userDefaults(store))
|
||||||
var notificationSettingsEnabled
|
var notificationSettingsEnabled
|
||||||
|
|
||||||
@UserPreference(key: UserDefaultsKeys.timelineDiffableAnimationsEnabled, defaultValue: false, storageType: .userDefaults(store))
|
|
||||||
var timelineDiffableAnimationsEnabled
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,10 +123,6 @@ class TimelineTableViewController: UIViewController {
|
|||||||
}
|
}
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
|
|
||||||
ServiceLocator.shared.settings.$timelineDiffableAnimationsEnabled
|
|
||||||
.weakAssign(to: \.shouldAnimate, on: self)
|
|
||||||
.store(in: &cancellables)
|
|
||||||
|
|
||||||
configureDataSource()
|
configureDataSource()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,12 +133,13 @@ class TimelineTableViewController: UIViewController {
|
|||||||
super.viewWillAppear(animated)
|
super.viewWillAppear(animated)
|
||||||
|
|
||||||
guard !hasAppearedOnce else { return }
|
guard !hasAppearedOnce else { return }
|
||||||
scrollToBottom(animated: false)
|
tableView.contentOffset.y = -1
|
||||||
hasAppearedOnce = true
|
hasAppearedOnce = true
|
||||||
paginateBackwardsPublisher.send()
|
paginateBackwardsPublisher.send()
|
||||||
|
|
||||||
// We never want the table view to be fully at the bottom to allow the status bar tap to work properly
|
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
|
||||||
tableView.contentOffset.y = -1
|
self.shouldAnimate = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override func viewWillLayoutSubviews() {
|
override func viewWillLayoutSubviews() {
|
||||||
@@ -213,18 +210,24 @@ class TimelineTableViewController: UIViewController {
|
|||||||
|
|
||||||
// We only animate when new items come at the end of the timeline
|
// We only animate when new items come at the end of the timeline
|
||||||
let animated = shouldAnimate &&
|
let animated = shouldAnimate &&
|
||||||
hasAppearedOnce &&
|
|
||||||
snapshot.itemIdentifiers.first != currentSnapshot.itemIdentifiers.first
|
snapshot.itemIdentifiers.first != currentSnapshot.itemIdentifiers.first
|
||||||
dataSource.apply(snapshot, animatingDifferences: animated)
|
dataSource.apply(snapshot, animatingDifferences: animated)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Scrolls to the bottom of the timeline.
|
/// Scrolls to the bottom of the timeline.
|
||||||
private func scrollToBottom(animated: Bool) {
|
private func scrollToBottom(animated: Bool) {
|
||||||
|
guard !timelineItemsIDs.isEmpty else {
|
||||||
|
return
|
||||||
|
}
|
||||||
tableView.scrollToRow(at: IndexPath(item: 0, section: 0), at: .top, animated: animated)
|
tableView.scrollToRow(at: IndexPath(item: 0, section: 0), at: .top, animated: animated)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Scrolls to the top of the timeline.
|
/// Scrolls to the top of the timeline.
|
||||||
private func scrollToTop(animated: Bool) {
|
private func scrollToTop(animated: Bool) {
|
||||||
|
let index = timelineItemsIDs.count - 1
|
||||||
|
guard index >= 0 else {
|
||||||
|
return
|
||||||
|
}
|
||||||
tableView.scrollToRow(at: IndexPath(item: timelineItemsIDs.count - 1, section: 0), at: .bottom, animated: animated)
|
tableView.scrollToRow(at: IndexPath(item: timelineItemsIDs.count - 1, section: 0), at: .bottom, animated: animated)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-2
@@ -30,7 +30,6 @@ struct DeveloperOptionsScreenViewStateBindings {
|
|||||||
var readReceiptsEnabled: Bool
|
var readReceiptsEnabled: Bool
|
||||||
var isEncryptionSyncEnabled: Bool
|
var isEncryptionSyncEnabled: Bool
|
||||||
var notificationSettingsEnabled: Bool
|
var notificationSettingsEnabled: Bool
|
||||||
var timelineDiffableAnimationsEnabled: Bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum DeveloperOptionsScreenViewAction {
|
enum DeveloperOptionsScreenViewAction {
|
||||||
@@ -39,6 +38,5 @@ enum DeveloperOptionsScreenViewAction {
|
|||||||
case changedReadReceiptsEnabled
|
case changedReadReceiptsEnabled
|
||||||
case changedIsEncryptionSyncEnabled
|
case changedIsEncryptionSyncEnabled
|
||||||
case changedNotificationSettingsEnabled
|
case changedNotificationSettingsEnabled
|
||||||
case changedTimelineDiffableAnimationsEnabled
|
|
||||||
case clearCache
|
case clearCache
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-4
@@ -30,8 +30,7 @@ class DeveloperOptionsScreenViewModel: DeveloperOptionsScreenViewModelType, Deve
|
|||||||
userSuggestionsEnabled: appSettings.userSuggestionsEnabled,
|
userSuggestionsEnabled: appSettings.userSuggestionsEnabled,
|
||||||
readReceiptsEnabled: appSettings.readReceiptsEnabled,
|
readReceiptsEnabled: appSettings.readReceiptsEnabled,
|
||||||
isEncryptionSyncEnabled: appSettings.isEncryptionSyncEnabled,
|
isEncryptionSyncEnabled: appSettings.isEncryptionSyncEnabled,
|
||||||
notificationSettingsEnabled: appSettings.notificationSettingsEnabled,
|
notificationSettingsEnabled: appSettings.notificationSettingsEnabled)
|
||||||
timelineDiffableAnimationsEnabled: appSettings.timelineDiffableAnimationsEnabled)
|
|
||||||
let state = DeveloperOptionsScreenViewState(bindings: bindings)
|
let state = DeveloperOptionsScreenViewState(bindings: bindings)
|
||||||
|
|
||||||
super.init(initialViewState: state)
|
super.init(initialViewState: state)
|
||||||
@@ -53,8 +52,6 @@ class DeveloperOptionsScreenViewModel: DeveloperOptionsScreenViewModelType, Deve
|
|||||||
appSettings.isEncryptionSyncEnabled = state.bindings.isEncryptionSyncEnabled
|
appSettings.isEncryptionSyncEnabled = state.bindings.isEncryptionSyncEnabled
|
||||||
case .changedNotificationSettingsEnabled:
|
case .changedNotificationSettingsEnabled:
|
||||||
appSettings.notificationSettingsEnabled = state.bindings.notificationSettingsEnabled
|
appSettings.notificationSettingsEnabled = state.bindings.notificationSettingsEnabled
|
||||||
case .changedTimelineDiffableAnimationsEnabled:
|
|
||||||
appSettings.timelineDiffableAnimationsEnabled = state.bindings.timelineDiffableAnimationsEnabled
|
|
||||||
case .clearCache:
|
case .clearCache:
|
||||||
callback?(.clearCache)
|
callback?(.clearCache)
|
||||||
}
|
}
|
||||||
|
|||||||
-7
@@ -63,13 +63,6 @@ struct DeveloperOptionsScreen: View {
|
|||||||
.onChange(of: context.userSuggestionsEnabled) { _ in
|
.onChange(of: context.userSuggestionsEnabled) { _ in
|
||||||
context.send(viewAction: .changedUserSuggestionsEnabled)
|
context.send(viewAction: .changedUserSuggestionsEnabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
Toggle(isOn: $context.timelineDiffableAnimationsEnabled) {
|
|
||||||
Text("Enable diffable animations in the timeline")
|
|
||||||
}
|
|
||||||
.onChange(of: context.timelineDiffableAnimationsEnabled) { _ in
|
|
||||||
context.send(viewAction: .changedTimelineDiffableAnimationsEnabled)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Section {
|
Section {
|
||||||
|
|||||||
Reference in New Issue
Block a user