parent
77ab2c3753
commit
b64c748b73
|
@ -114,6 +114,19 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
self.reapplyFilters(actionsChanged: actionsChanged)
|
||||
}
|
||||
|
||||
let jumpToPresentName = NSMutableAttributedString("Jump to Present")
|
||||
// otherwise it pronounces it as 'pɹizˈənt'
|
||||
// its IPA is also bad, this should be an alveolar approximant not a trill
|
||||
jumpToPresentName.addAttribute(.accessibilitySpeechIPANotation, value: "ˈprɛ.zənt", range: NSRange(location: "Jump to ".count, length: "Present".count))
|
||||
accessibilityCustomActions = [
|
||||
UIAccessibilityCustomAction(attributedName: jumpToPresentName, actionHandler: { [unowned self] _ in
|
||||
Task {
|
||||
await self.checkPresent(jumpImmediately: true)
|
||||
}
|
||||
return true
|
||||
})
|
||||
]
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(sceneWillEnterForeground), name: UIScene.willEnterForegroundNotification, object: nil)
|
||||
}
|
||||
|
||||
|
@ -192,7 +205,7 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
if case .notLoadedInitial = controller.state {
|
||||
if doRestore() {
|
||||
Task {
|
||||
await checkPresent()
|
||||
await checkPresent(jumpImmediately: false)
|
||||
}
|
||||
} else {
|
||||
Task {
|
||||
|
@ -376,7 +389,7 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
return
|
||||
}
|
||||
Task {
|
||||
await checkPresent()
|
||||
await checkPresent(jumpImmediately: false)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -405,12 +418,22 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
}
|
||||
}
|
||||
|
||||
private func checkPresent() async {
|
||||
private func checkPresent(jumpImmediately: Bool) async {
|
||||
if case .idle = controller.state,
|
||||
let presentItems = try? await loadInitial() {
|
||||
let presentItems = try? await loadInitial(),
|
||||
!presentItems.isEmpty {
|
||||
if jumpImmediately {
|
||||
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
|
||||
snapshot.appendSections([.statuses])
|
||||
snapshot.appendItems(presentItems.map { .status(id: $0, collapseState: .unknown, filterState: .unknown) }, toSection: .statuses)
|
||||
dataSource.apply(snapshot, animatingDifferences: true) {
|
||||
UIAccessibility.post(notification: .screenChanged, argument: self.collectionView.cellForItem(at: IndexPath(row: 0, section: 0)))
|
||||
}
|
||||
} else {
|
||||
insertPresentItemsIfNecessary(presentItems)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func insertPresentItemsIfNecessary(_ presentItems: [String]) {
|
||||
let snapshot = dataSource.snapshot()
|
||||
|
|
Loading…
Reference in New Issue