forked from zelo72/mastodon-ios
fix: app may not response to link for some server issue. ticket: #18624MBA
This commit is contained in:
parent
5fa78394a3
commit
d9c0c75782
|
@ -4841,7 +4841,7 @@
|
||||||
repositoryURL = "https://github.com/TwidereProject/MetaTextView.git";
|
repositoryURL = "https://github.com/TwidereProject/MetaTextView.git";
|
||||||
requirement = {
|
requirement = {
|
||||||
kind = exactVersion;
|
kind = exactVersion;
|
||||||
version = 1.3.0;
|
version = 1.3.1;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
DB0E2D2C26833FF600865C3C /* XCRemoteSwiftPackageReference "Nuke-FLAnimatedImage-Plugin" */ = {
|
DB0E2D2C26833FF600865C3C /* XCRemoteSwiftPackageReference "Nuke-FLAnimatedImage-Plugin" */ = {
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<key>CoreDataStack.xcscheme_^#shared#^_</key>
|
<key>CoreDataStack.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>20</integer>
|
<integer>21</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>Mastodon - ASDK.xcscheme_^#shared#^_</key>
|
<key>Mastodon - ASDK.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
<key>NotificationService.xcscheme_^#shared#^_</key>
|
<key>NotificationService.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>21</integer>
|
<integer>22</integer>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
<key>SuppressBuildableAutocreation</key>
|
<key>SuppressBuildableAutocreation</key>
|
||||||
|
|
|
@ -114,8 +114,8 @@
|
||||||
"repositoryURL": "https://github.com/TwidereProject/MetaTextView.git",
|
"repositoryURL": "https://github.com/TwidereProject/MetaTextView.git",
|
||||||
"state": {
|
"state": {
|
||||||
"branch": null,
|
"branch": null,
|
||||||
"revision": "e2049e14ef411c6810d53c1baf553b5161c6678f",
|
"revision": "9021b330dd72898583f62ee7f4c98768d72e7654",
|
||||||
"version": "1.3.0"
|
"version": "1.3.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -128,12 +128,10 @@ extension StatusProviderFacade {
|
||||||
|
|
||||||
static func responseToStatusActiveLabelAction(provider: StatusProvider, cell: UITableViewCell, activeLabel: ActiveLabel, didTapEntity entity: ActiveEntity) {
|
static func responseToStatusActiveLabelAction(provider: StatusProvider, cell: UITableViewCell, activeLabel: ActiveLabel, didTapEntity entity: ActiveEntity) {
|
||||||
switch entity.type {
|
switch entity.type {
|
||||||
case .hashtag(let text, _):
|
case .url(_, _, let url, _),
|
||||||
let hashtagTimelienViewModel = HashtagTimelineViewModel(context: provider.context, hashtag: text)
|
.mention(let url, _) where url.lowercased().hasPrefix("http"):
|
||||||
provider.coordinator.present(scene: .hashtagTimeline(viewModel: hashtagTimelienViewModel), from: provider, transition: .show)
|
// note:
|
||||||
case .mention(let text, _):
|
// some server mark the normal url as "u-url" class. :
|
||||||
coordinateToStatusMentionProfileScene(for: .primary, provider: provider, cell: cell, mention: text)
|
|
||||||
case .url(_, _, let url, _):
|
|
||||||
guard let url = URL(string: url) else { return }
|
guard let url = URL(string: url) else { return }
|
||||||
if let domain = provider.context.authenticationService.activeMastodonAuthenticationBox.value?.domain, url.host == domain,
|
if let domain = provider.context.authenticationService.activeMastodonAuthenticationBox.value?.domain, url.host == domain,
|
||||||
url.pathComponents.count >= 4,
|
url.pathComponents.count >= 4,
|
||||||
|
@ -146,6 +144,12 @@ extension StatusProviderFacade {
|
||||||
} else {
|
} else {
|
||||||
provider.coordinator.present(scene: .safari(url: url), from: nil, transition: .safariPresent(animated: true, completion: nil))
|
provider.coordinator.present(scene: .safari(url: url), from: nil, transition: .safariPresent(animated: true, completion: nil))
|
||||||
}
|
}
|
||||||
|
case .hashtag(let text, _):
|
||||||
|
let hashtagTimelienViewModel = HashtagTimelineViewModel(context: provider.context, hashtag: text)
|
||||||
|
provider.coordinator.present(scene: .hashtagTimeline(viewModel: hashtagTimelienViewModel), from: provider, transition: .show)
|
||||||
|
case .mention(let text, let userInfo):
|
||||||
|
let href = userInfo?["href"] as? String
|
||||||
|
coordinateToStatusMentionProfileScene(for: .primary, provider: provider, cell: cell, mention: text, href: href)
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -153,7 +157,10 @@ extension StatusProviderFacade {
|
||||||
|
|
||||||
static func responseToStatusMetaTextAction(provider: StatusProvider, cell: UITableViewCell, metaText: MetaText, didSelectMeta meta: Meta) {
|
static func responseToStatusMetaTextAction(provider: StatusProvider, cell: UITableViewCell, metaText: MetaText, didSelectMeta meta: Meta) {
|
||||||
switch meta {
|
switch meta {
|
||||||
case .url(_, _, let url, _):
|
case .url(_, _, let url, _),
|
||||||
|
.mention(_, let url, _) where url.lowercased().hasPrefix("http"):
|
||||||
|
// note:
|
||||||
|
// some server mark the normal url as "u-url" class. highlighted content is a URL
|
||||||
guard let url = URL(string: url) else { return }
|
guard let url = URL(string: url) else { return }
|
||||||
if let domain = provider.context.authenticationService.activeMastodonAuthenticationBox.value?.domain, url.host == domain,
|
if let domain = provider.context.authenticationService.activeMastodonAuthenticationBox.value?.domain, url.host == domain,
|
||||||
url.pathComponents.count >= 4,
|
url.pathComponents.count >= 4,
|
||||||
|
@ -169,8 +176,9 @@ extension StatusProviderFacade {
|
||||||
case .hashtag(_, let hashtag, _):
|
case .hashtag(_, let hashtag, _):
|
||||||
let hashtagTimelineViewModel = HashtagTimelineViewModel(context: provider.context, hashtag: hashtag)
|
let hashtagTimelineViewModel = HashtagTimelineViewModel(context: provider.context, hashtag: hashtag)
|
||||||
provider.coordinator.present(scene: .hashtagTimeline(viewModel: hashtagTimelineViewModel), from: provider, transition: .show)
|
provider.coordinator.present(scene: .hashtagTimeline(viewModel: hashtagTimelineViewModel), from: provider, transition: .show)
|
||||||
case .mention(_, let mention, _):
|
case .mention(_, let mention, let userInfo):
|
||||||
coordinateToStatusMentionProfileScene(for: .primary, provider: provider, cell: cell, mention: mention)
|
let href = userInfo?["href"] as? String
|
||||||
|
coordinateToStatusMentionProfileScene(for: .primary, provider: provider, cell: cell, mention: mention, href: href)
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -208,17 +216,17 @@ extension StatusProviderFacade {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private static func coordinateToStatusMentionProfileScene(for target: Target, provider: StatusProvider, cell: UITableViewCell, mention: String) {
|
private static func coordinateToStatusMentionProfileScene(for target: Target, provider: StatusProvider, cell: UITableViewCell, mention: String, href: String?) {
|
||||||
provider.status(for: cell, indexPath: nil)
|
provider.status(for: cell, indexPath: nil)
|
||||||
.sink { [weak provider] status in
|
.sink { [weak provider] status in
|
||||||
guard let provider = provider else { return }
|
guard let provider = provider else { return }
|
||||||
guard let status = status else { return }
|
guard let status = status else { return }
|
||||||
coordinateToStatusMentionProfileScene(for: target, provider: provider, status: status, mention: mention)
|
coordinateToStatusMentionProfileScene(for: target, provider: provider, status: status, mention: mention, href: href)
|
||||||
}
|
}
|
||||||
.store(in: &provider.disposeBag)
|
.store(in: &provider.disposeBag)
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func coordinateToStatusMentionProfileScene(for target: Target, provider: StatusProvider, status: Status, mention: String) {
|
private static func coordinateToStatusMentionProfileScene(for target: Target, provider: StatusProvider, status: Status, mention: String, href: String?) {
|
||||||
guard let activeMastodonAuthenticationBox = provider.context.authenticationService.activeMastodonAuthenticationBox.value else { return }
|
guard let activeMastodonAuthenticationBox = provider.context.authenticationService.activeMastodonAuthenticationBox.value else { return }
|
||||||
let domain = activeMastodonAuthenticationBox.domain
|
let domain = activeMastodonAuthenticationBox.domain
|
||||||
|
|
||||||
|
@ -230,7 +238,13 @@ extension StatusProviderFacade {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// cannot continue without meta
|
// cannot continue without meta
|
||||||
guard let mentionMeta = (status.mentions ?? Set()).first(where: { $0.username == mention }) else { return }
|
guard let mentionMeta = (status.mentions ?? Set()).first(where: { $0.username == mention }) else {
|
||||||
|
// present web page if possible
|
||||||
|
if let url = href.flatMap({ URL(string: $0) }) {
|
||||||
|
provider.coordinator.present(scene: .safari(url: url), from: provider, transition: .safariPresent(animated: true, completion: nil))
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let userID = mentionMeta.id
|
let userID = mentionMeta.id
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue