Compare commits

...

3 Commits

5 changed files with 21 additions and 9 deletions

View File

@ -85,7 +85,7 @@ public class Client {
} }
guard response.statusCode == 200 else { guard response.statusCode == 200 else {
let mastodonError = try? Client.decoder.decode(MastodonError.self, from: data) let mastodonError = try? Client.decoder.decode(MastodonError.self, from: data)
let type: ErrorType = mastodonError.flatMap { .mastodonError($0.description) } ?? .unexpectedStatus(response.statusCode) let type: ErrorType = mastodonError.flatMap { .mastodonError(response.statusCode, $0.description) } ?? .unexpectedStatus(response.statusCode)
completion(.failure(Error(request: request, type: type))) completion(.failure(Error(request: request, type: type)))
return return
} }
@ -462,8 +462,8 @@ extension Client {
return "Invalid Response" return "Invalid Response"
case .invalidModel(_): case .invalidModel(_):
return "Invalid Model" return "Invalid Model"
case .mastodonError(let error): case .mastodonError(let code, let error):
return "Server Error: \(error)" return "Server Error (\(code)): \(error)"
} }
} }
} }
@ -473,6 +473,6 @@ extension Client {
case invalidRequest case invalidRequest
case invalidResponse case invalidResponse
case invalidModel(Swift.Error) case invalidModel(Swift.Error)
case mastodonError(String) case mastodonError(Int, String)
} }
} }

View File

@ -37,4 +37,8 @@ class AccountActivityItemSource: NSObject, UIActivityItemSource {
return metadata return metadata
} }
func activityViewController(_ activityViewController: UIActivityViewController, subjectForActivityType activityType: UIActivity.ActivityType?) -> String {
return "\(account.displayName) (@\(account.acct)"
}
} }

View File

@ -40,4 +40,8 @@ class StatusActivityItemSource: NSObject, UIActivityItemSource {
return metadata return metadata
} }
func activityViewController(_ activityViewController: UIActivityViewController, subjectForActivityType activityType: UIActivity.ActivityType?) -> String {
return "Post by @\(status.account.acct)"
}
} }

View File

@ -621,9 +621,12 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
snapshot.insertItems(presentItems.map { .status(id: $0, collapseState: .unknown, filterState: .unknown) }, beforeItem: .gap) snapshot.insertItems(presentItems.map { .status(id: $0, collapseState: .unknown, filterState: .unknown) }, beforeItem: .gap)
if applySnapshotBeforeScrolling { if applySnapshotBeforeScrolling {
let firstVisibleIndexPath = collectionView.indexPathsForVisibleItems.min()! if let firstVisibleIndexPath = collectionView.indexPathsForVisibleItems.min() {
let firstVisibleItem = dataSource.itemIdentifier(for: firstVisibleIndexPath)! let firstVisibleItem = dataSource.itemIdentifier(for: firstVisibleIndexPath)!
applySnapshot(snapshot, maintainingBottomRelativeScrollPositionOf: firstVisibleItem) applySnapshot(snapshot, maintainingBottomRelativeScrollPositionOf: firstVisibleItem)
} else {
dataSource.apply(snapshot, animatingDifferences: false)
}
} }
var config = ToastConfiguration(title: "Jump to Present") var config = ToastConfiguration(title: "Jump to Present")

View File

@ -57,7 +57,7 @@ extension ToastConfiguration {
} }
// TODO: this is a bizarre place to do this, but code path covers basically all errors // TODO: this is a bizarre place to do this, but code path covers basically all errors
switch error.type { switch error.type {
case .invalidRequest, .invalidResponse, .invalidModel(_), .mastodonError(_): case .invalidRequest, .invalidResponse, .invalidModel(_), .mastodonError(_, _):
let event = Event(error: error) let event = Event(error: error)
event.message = SentryMessage(formatted: "\(title): \(error)") event.message = SentryMessage(formatted: "\(title): \(error)")
event.tags = [ event.tags = [
@ -72,8 +72,9 @@ extension ToastConfiguration {
case .invalidModel(let error): case .invalidModel(let error):
event.tags!["error_type"] = "invalid_model" event.tags!["error_type"] = "invalid_model"
event.tags!["underlying_error"] = String(describing: error) event.tags!["underlying_error"] = String(describing: error)
case .mastodonError(let error): case .mastodonError(let code, let error):
event.tags!["error_type"] = "mastodon_error" event.tags!["error_type"] = "mastodon_error"
event.tags!["response_code"] = "\(code)"
event.tags!["underlying_error"] = error event.tags!["underlying_error"] = error
default: default:
break break