forked from shadowfacts/Tusker
parent
77ab2c3753
commit
b64c748b73
|
@ -114,6 +114,19 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
||||||
self.reapplyFilters(actionsChanged: actionsChanged)
|
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)
|
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 case .notLoadedInitial = controller.state {
|
||||||
if doRestore() {
|
if doRestore() {
|
||||||
Task {
|
Task {
|
||||||
await checkPresent()
|
await checkPresent(jumpImmediately: false)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Task {
|
Task {
|
||||||
|
@ -376,7 +389,7 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Task {
|
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,
|
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)
|
insertPresentItemsIfNecessary(presentItems)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private func insertPresentItemsIfNecessary(_ presentItems: [String]) {
|
private func insertPresentItemsIfNecessary(_ presentItems: [String]) {
|
||||||
let snapshot = dataSource.snapshot()
|
let snapshot = dataSource.snapshot()
|
||||||
|
|
Loading…
Reference in New Issue