mirror of
https://github.com/mastodon/mastodon-ios.git
synced 2025-02-04 03:07:44 +01:00
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 {
|
enum DefaultSectionEntry: Hashable {
|
||||||
case posts(String)
|
case posts(String)
|
||||||
case people(String)
|
case people(String)
|
||||||
case profile(String, String)
|
case profile(username: String, domain: String)
|
||||||
case openLink(String)
|
case openLink(String)
|
||||||
|
|
||||||
var title: String {
|
var title: String {
|
||||||
|
@ -123,8 +123,20 @@ class SearchResultsOverviewTableViewController: UIViewController, NeedsDependenc
|
|||||||
var snapshot = dataSource.snapshot()
|
var snapshot = dataSource.snapshot()
|
||||||
snapshot.deleteItems(snapshot.itemIdentifiers(inSection: .default))
|
snapshot.deleteItems(snapshot.itemIdentifiers(inSection: .default))
|
||||||
snapshot.appendItems([.default(.posts(searchText)),
|
snapshot.appendItems([.default(.posts(searchText)),
|
||||||
.default(.people(searchText)),
|
.default(.people(searchText))], toSection: .default)
|
||||||
.default(.profile(searchText, authContext.mastodonAuthenticationBox.domain))], 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 {
|
if URL(string: searchText)?.isValidURL() ?? false {
|
||||||
snapshot.appendItems([.default(.openLink(searchText))], toSection: .default)
|
snapshot.appendItems([.default(.openLink(searchText))], toSection: .default)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user