Merge remote-tracking branch 'refs/remotes/origin/master'
Conflicts: LiquipediaMenu.xcworkspace/xcuserdata/felixfoertsch.xcuserdatad/UserInterfaceState.xcuserstate LiquipediaMenu/StatusBarController.swift
This commit is contained in:
@@ -9,10 +9,6 @@
|
||||
import Foundation
|
||||
import SwiftSoup
|
||||
|
||||
protocol MatchesAPIDelegate {
|
||||
|
||||
}
|
||||
|
||||
class MatchesAPI {
|
||||
|
||||
func fetchMatches(for game: String) -> [Match]? {
|
||||
@@ -26,13 +22,9 @@ class MatchesAPI {
|
||||
|
||||
private func fetchData(for game: String) -> String? {
|
||||
let url = constructURL(for: game)
|
||||
// DispatchQueue.global().async { [unowned self] in
|
||||
if let url = URL(string: url) {
|
||||
if let data = try? String(contentsOf: url) {
|
||||
return data
|
||||
}
|
||||
}
|
||||
// }
|
||||
if let data = try? String(contentsOf: url) {
|
||||
return data
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -73,10 +65,10 @@ class MatchesAPI {
|
||||
}
|
||||
}
|
||||
|
||||
private func constructURL(for game: String) -> String {
|
||||
private func constructURL(for game: String) -> URL {
|
||||
let baseURL = "https://liquipedia.net/"
|
||||
let query = "/api.php?action=parse&page=Liquipedia:Upcoming_and_ongoing_matches&format=json&prop=text"
|
||||
return baseURL + game + query
|
||||
return URL(string: baseURL + game + query)!
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,12 +9,13 @@
|
||||
import Cocoa
|
||||
|
||||
class StatusBarController: NSObject, NSMenuItemValidation {
|
||||
|
||||
func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
|
||||
return true
|
||||
}
|
||||
|
||||
let statusBar = NSMenu()
|
||||
let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
|
||||
let statusBarItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
|
||||
let matchesAPI = MatchesAPI()
|
||||
var matches = [Match]()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user