avoid problems

This commit is contained in:
Mauro Romito
2023-07-21 11:01:12 +02:00
committed by Mauro
parent 8bd586d441
commit dff679d994
5 changed files with 12 additions and 25 deletions

View File

@@ -34,7 +34,6 @@ final class AppSettings {
case readReceiptsEnabled
case hasShownWelcomeScreen
case notificationSettingsEnabled
case timelineDiffableAnimationsEnabled
}
private static var suiteName: String = InfoPlistReader.main.appGroupIdentifier
@@ -218,7 +217,4 @@ final class AppSettings {
@UserPreference(key: UserDefaultsKeys.notificationSettingsEnabled, defaultValue: false, storageType: .userDefaults(store))
var notificationSettingsEnabled
@UserPreference(key: UserDefaultsKeys.timelineDiffableAnimationsEnabled, defaultValue: false, storageType: .userDefaults(store))
var timelineDiffableAnimationsEnabled
}

View File

@@ -122,10 +122,6 @@ class TimelineTableViewController: UIViewController {
self?.paginateBackwardsIfNeeded()
}
.store(in: &cancellables)
ServiceLocator.shared.settings.$timelineDiffableAnimationsEnabled
.weakAssign(to: \.shouldAnimate, on: self)
.store(in: &cancellables)
configureDataSource()
}
@@ -137,12 +133,13 @@ class TimelineTableViewController: UIViewController {
super.viewWillAppear(animated)
guard !hasAppearedOnce else { return }
scrollToBottom(animated: false)
tableView.contentOffset.y = -1
hasAppearedOnce = true
paginateBackwardsPublisher.send()
// We never want the table view to be fully at the bottom to allow the status bar tap to work properly
tableView.contentOffset.y = -1
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
self.shouldAnimate = true
}
}
override func viewWillLayoutSubviews() {
@@ -213,18 +210,24 @@ class TimelineTableViewController: UIViewController {
// We only animate when new items come at the end of the timeline
let animated = shouldAnimate &&
hasAppearedOnce &&
snapshot.itemIdentifiers.first != currentSnapshot.itemIdentifiers.first
dataSource.apply(snapshot, animatingDifferences: animated)
}
/// Scrolls to the bottom of the timeline.
private func scrollToBottom(animated: Bool) {
guard !timelineItemsIDs.isEmpty else {
return
}
tableView.scrollToRow(at: IndexPath(item: 0, section: 0), at: .top, animated: animated)
}
/// Scrolls to the top of the timeline.
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)
}

View File

@@ -30,7 +30,6 @@ struct DeveloperOptionsScreenViewStateBindings {
var readReceiptsEnabled: Bool
var isEncryptionSyncEnabled: Bool
var notificationSettingsEnabled: Bool
var timelineDiffableAnimationsEnabled: Bool
}
enum DeveloperOptionsScreenViewAction {
@@ -39,6 +38,5 @@ enum DeveloperOptionsScreenViewAction {
case changedReadReceiptsEnabled
case changedIsEncryptionSyncEnabled
case changedNotificationSettingsEnabled
case changedTimelineDiffableAnimationsEnabled
case clearCache
}

View File

@@ -30,8 +30,7 @@ class DeveloperOptionsScreenViewModel: DeveloperOptionsScreenViewModelType, Deve
userSuggestionsEnabled: appSettings.userSuggestionsEnabled,
readReceiptsEnabled: appSettings.readReceiptsEnabled,
isEncryptionSyncEnabled: appSettings.isEncryptionSyncEnabled,
notificationSettingsEnabled: appSettings.notificationSettingsEnabled,
timelineDiffableAnimationsEnabled: appSettings.timelineDiffableAnimationsEnabled)
notificationSettingsEnabled: appSettings.notificationSettingsEnabled)
let state = DeveloperOptionsScreenViewState(bindings: bindings)
super.init(initialViewState: state)
@@ -53,8 +52,6 @@ class DeveloperOptionsScreenViewModel: DeveloperOptionsScreenViewModelType, Deve
appSettings.isEncryptionSyncEnabled = state.bindings.isEncryptionSyncEnabled
case .changedNotificationSettingsEnabled:
appSettings.notificationSettingsEnabled = state.bindings.notificationSettingsEnabled
case .changedTimelineDiffableAnimationsEnabled:
appSettings.timelineDiffableAnimationsEnabled = state.bindings.timelineDiffableAnimationsEnabled
case .clearCache:
callback?(.clearCache)
}

View File

@@ -63,13 +63,6 @@ struct DeveloperOptionsScreen: View {
.onChange(of: context.userSuggestionsEnabled) { _ in
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 {