Compare commits
No commits in common. "126e8c88582694425d52095bdc37f6b16d1e60e7" and "361ce456cf95972a967e35ed1a3eaae44c0d26f1" have entirely different histories.
126e8c8858
...
361ce456cf
|
@ -11,13 +11,6 @@ import Pachyderm
|
|||
import WebURL
|
||||
import WebURLFoundationExtras
|
||||
|
||||
private let mastodonRemoteStatusRegex = try! NSRegularExpression(pattern: "^/@.+@.+/\\d{18}")
|
||||
private func isLikelyMastodonRemoteStatus(url: URL) -> Bool {
|
||||
let path = url.path
|
||||
let range = NSRange(location: 0, length: path.utf16.count)
|
||||
return mastodonRemoteStatusRegex.numberOfMatches(in: path, range: range) == 1
|
||||
}
|
||||
|
||||
class ConversationViewController: UIViewController {
|
||||
|
||||
weak var mastodonController: MastodonController!
|
||||
|
@ -217,24 +210,11 @@ class ConversationViewController: UIViewController {
|
|||
indicator.startAnimating()
|
||||
state = .loading(indicator)
|
||||
|
||||
let effectiveURL: String
|
||||
class RedirectBlocker: NSObject, URLSessionTaskDelegate {
|
||||
func urlSession(_ session: URLSession, task: URLSessionTask, willPerformHTTPRedirection response: HTTPURLResponse, newRequest request: URLRequest, completionHandler: @escaping (URLRequest?) -> Void) {
|
||||
completionHandler(nil)
|
||||
}
|
||||
}
|
||||
if isLikelyMastodonRemoteStatus(url: url),
|
||||
let (_, response) = try? await URLSession.shared.data(from: url, delegate: RedirectBlocker()),
|
||||
let location = (response as? HTTPURLResponse)?.value(forHTTPHeaderField: "location") {
|
||||
effectiveURL = location
|
||||
} else {
|
||||
effectiveURL = WebURL(url)!.serialized(excludingFragment: true)
|
||||
}
|
||||
|
||||
let request = Client.search(query: effectiveURL, types: [.statuses], resolve: true)
|
||||
let url = WebURL(url)!.serialized(excludingFragment: true)
|
||||
let request = Client.search(query: url, types: [.statuses], resolve: true)
|
||||
do {
|
||||
let (results, _) = try await mastodonController.run(request)
|
||||
guard let status = results.statuses.first(where: { $0.url?.serialized() == effectiveURL }) else {
|
||||
guard let status = results.statuses.first(where: { $0.url?.serialized() == url }) else {
|
||||
throw UnableToResolveError()
|
||||
}
|
||||
_ = mastodonController.persistentContainer.addOrUpdateOnViewContext(status: status)
|
||||
|
|
|
@ -144,15 +144,7 @@ class ExpandThreadCollectionViewCell: UICollectionViewListCell {
|
|||
}
|
||||
|
||||
override func updateConfiguration(using state: UICellConfigurationState) {
|
||||
var config = UIBackgroundConfiguration.listGroupedCell().updated(for: state)
|
||||
if state.isFocused {
|
||||
// use default
|
||||
} else if state.isHighlighted || state.isSelected {
|
||||
config.backgroundColor = .appSelectedCellBackground
|
||||
} else {
|
||||
config.backgroundColor = .appSecondaryBackground
|
||||
}
|
||||
backgroundConfiguration = config
|
||||
backgroundConfiguration = .appListPlainCell(for: state)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -115,14 +115,6 @@ class MainSplitViewController: UISplitViewController {
|
|||
}
|
||||
}
|
||||
|
||||
override func show(_ vc: UIViewController, sender: Any?) {
|
||||
if traitCollection.horizontalSizeClass == .regular {
|
||||
secondaryNavController.show(vc, sender: sender)
|
||||
} else {
|
||||
super.show(vc, sender: sender)
|
||||
}
|
||||
}
|
||||
|
||||
@objc func handleSidebarCommandTimelines() {
|
||||
sidebar.select(item: .tab(.timelines), animated: false)
|
||||
select(item: .tab(.timelines))
|
||||
|
|
|
@ -305,11 +305,9 @@ private class SplitSecondaryNavigationController: EnhancedNavigationViewControll
|
|||
}
|
||||
|
||||
override func pushViewController(_ viewController: UIViewController, animated: Bool) {
|
||||
if viewControllers.isEmpty {
|
||||
configureSecondarySplitCloseButton(for: viewController)
|
||||
}
|
||||
|
||||
super.pushViewController(viewController, animated: animated)
|
||||
|
||||
configureSecondarySplitCloseButton(for: viewControllers.first!)
|
||||
}
|
||||
|
||||
private func configureSecondarySplitCloseButton(for viewController: UIViewController) {
|
||||
|
|
|
@ -205,7 +205,6 @@ enum PopoverSource {
|
|||
private let statusPathRegex = try! NSRegularExpression(
|
||||
pattern:
|
||||
"(^/@[a-z0-9_]+/\\d{18})" // mastodon
|
||||
+ "|(^/@.+@.+/\\d{18})" // mastodon remote
|
||||
+ "|(^/notice/[a-z0-9]{18})" // pleroma
|
||||
+ "|(^/notes/[a-z0-9]{10})" // misskey
|
||||
+ "|(^/p/[a-z0-9_]+/\\d{18})" // pixelfed
|
||||
|
|
Loading…
Reference in New Issue