forked from shadowfacts/Tusker
Whoops
This commit is contained in:
parent
d5433e9b91
commit
c420c236d9
|
@ -2,6 +2,7 @@
|
|||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<array>
|
||||
<string>counter\.social</string>
|
||||
<string>gab\..+</string>
|
||||
</array>
|
||||
</plist>
|
||||
|
|
|
@ -18,6 +18,12 @@ fileprivate let instanceCell = "instanceCell"
|
|||
|
||||
class InstanceSelectorTableViewController: UITableViewController {
|
||||
|
||||
static var blocks: [NSRegularExpression] = {
|
||||
guard let path = Bundle.main.path(forResource: "DomainBlocks", ofType: "plist"),
|
||||
let array = NSArray(contentsOfFile: path) as? [String] else { return [] }
|
||||
return array.compactMap { try? NSRegularExpression(pattern: $0, options: .caseInsensitive) }
|
||||
}()
|
||||
|
||||
weak var delegate: InstanceSelectorTableViewControllerDelegate?
|
||||
|
||||
var dataSource: DataSource!
|
||||
|
@ -100,7 +106,7 @@ class InstanceSelectorTableViewController: UITableViewController {
|
|||
loadRecommendedInstances()
|
||||
}
|
||||
|
||||
private func parseURLComponents(input: String) -> URLComponents {
|
||||
private func parseURLComponents(input: String) -> URLComponents? {
|
||||
// we can't just use the URLComponents(string:) initializer, because when given just a domain (w/o protocol), it interprets it as the path
|
||||
var input = input
|
||||
var components = URLComponents()
|
||||
|
@ -125,13 +131,24 @@ class InstanceSelectorTableViewController: UITableViewController {
|
|||
components.port = Int(parts.last!)
|
||||
}
|
||||
components.host = input
|
||||
if Self.blocks.contains(where: { $0.numberOfMatches(in: input, range: NSRange(location: 0, length: input.utf16.count)) > 0 }) {
|
||||
return nil
|
||||
}
|
||||
return components
|
||||
}
|
||||
|
||||
private func updateSpecificInstance(domain: String) {
|
||||
activityIndicator.startAnimating()
|
||||
|
||||
let components = parseURLComponents(input: domain)
|
||||
guard let components = parseURLComponents(input: domain) else {
|
||||
var snapshot = dataSource.snapshot()
|
||||
if snapshot.indexOfSection(.selected) != nil {
|
||||
snapshot.deleteSections([.selected])
|
||||
dataSource.apply(snapshot)
|
||||
}
|
||||
activityIndicator.stopAnimating()
|
||||
return
|
||||
}
|
||||
let url = components.url!
|
||||
|
||||
let client = Client(baseURL: url, session: .appDefault)
|
||||
|
|
|
@ -17,12 +17,6 @@ protocol OnboardingViewControllerDelegate {
|
|||
|
||||
class OnboardingViewController: UINavigationController {
|
||||
|
||||
static var blocks: [NSRegularExpression] = {
|
||||
guard let path = Bundle.main.path(forResource: "DomainBlocks", ofType: "plist"),
|
||||
let array = NSArray(contentsOfFile: path) as? [String] else { return [] }
|
||||
return array.compactMap { try? NSRegularExpression(pattern: $0, options: .caseInsensitive) }
|
||||
}()
|
||||
|
||||
var onboardingDelegate: OnboardingViewControllerDelegate?
|
||||
|
||||
var instanceSelector = InstanceSelectorTableViewController()
|
||||
|
|
Loading…
Reference in New Issue