forked from shadowfacts/Tusker
Handle 401 errors on instance timelines
This commit is contained in:
parent
825424cfba
commit
c114749519
|
@ -84,8 +84,23 @@ class InstanceTimelineViewController: TimelineViewController {
|
||||||
// MARK: Timeline
|
// MARK: Timeline
|
||||||
|
|
||||||
override func handleLoadAllError(_ error: Swift.Error) async {
|
override func handleLoadAllError(_ error: Swift.Error) async {
|
||||||
switch (error as? Client.Error)?.type {
|
guard let error = error as? Client.Error else {
|
||||||
case .mastodonError(422, _), .unexpectedStatus(422):
|
await super.handleLoadAllError(error)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let code: Int
|
||||||
|
switch error.type {
|
||||||
|
case .mastodonError(let c, _), .unexpectedStatus(let c):
|
||||||
|
code = c
|
||||||
|
default:
|
||||||
|
await super.handleLoadAllError(error)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
guard code == 422 || code == 401 else {
|
||||||
|
await super.handleLoadAllError(error)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
collectionView.isHidden = true
|
collectionView.isHidden = true
|
||||||
view.backgroundColor = .systemBackground
|
view.backgroundColor = .systemBackground
|
||||||
|
|
||||||
|
@ -121,10 +136,6 @@ class InstanceTimelineViewController: TimelineViewController {
|
||||||
view.safeAreaLayoutGuide.trailingAnchor.constraint(equalToSystemSpacingAfter: stack.trailingAnchor, multiplier: 1),
|
view.safeAreaLayoutGuide.trailingAnchor.constraint(equalToSystemSpacingAfter: stack.trailingAnchor, multiplier: 1),
|
||||||
stack.centerYAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerYAnchor),
|
stack.centerYAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerYAnchor),
|
||||||
])
|
])
|
||||||
|
|
||||||
default:
|
|
||||||
await super.handleLoadAllError(error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Interaction
|
// MARK: Interaction
|
||||||
|
|
Loading…
Reference in New Issue