Consider mastodon-domains for other instances and profiles (IOS-141)
This commit is contained in:
parent
4378c1e971
commit
cb4c5a938d
|
@ -17,7 +17,7 @@ enum SearchResultOverviewItem: Hashable {
|
|||
enum DefaultSectionEntry: Hashable {
|
||||
case posts(String)
|
||||
case people(String)
|
||||
case profile(String, String)
|
||||
case profile(username: String, domain: String)
|
||||
case openLink(String)
|
||||
|
||||
var title: String {
|
||||
|
|
|
@ -123,8 +123,20 @@ class SearchResultsOverviewTableViewController: UIViewController, NeedsDependenc
|
|||
var snapshot = dataSource.snapshot()
|
||||
snapshot.deleteItems(snapshot.itemIdentifiers(inSection: .default))
|
||||
snapshot.appendItems([.default(.posts(searchText)),
|
||||
.default(.people(searchText)),
|
||||
.default(.profile(searchText, authContext.mastodonAuthenticationBox.domain))], toSection: .default)
|
||||
.default(.people(searchText))], toSection: .default)
|
||||
let components = searchText.split(separator: "@")
|
||||
if components.count == 2 {
|
||||
let username = String(components[0])
|
||||
|
||||
let domain = String(components[1])
|
||||
if domain.split(separator: ".").count >= 2 {
|
||||
snapshot.appendItems([.default(.profile(username: username, domain: domain))], toSection: .default)
|
||||
} else {
|
||||
snapshot.appendItems([.default(.profile(username: username, domain: authContext.mastodonAuthenticationBox.domain))], toSection: .default)
|
||||
}
|
||||
} else {
|
||||
snapshot.appendItems([.default(.profile(username: searchText, domain: authContext.mastodonAuthenticationBox.domain))], toSection: .default)
|
||||
}
|
||||
|
||||
if URL(string: searchText)?.isValidURL() ?? false {
|
||||
snapshot.appendItems([.default(.openLink(searchText))], toSection: .default)
|
||||
|
|
Loading…
Reference in New Issue