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 Foundation
|
||||||
import SwiftSoup
|
import SwiftSoup
|
||||||
|
|
||||||
protocol MatchesAPIDelegate {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class MatchesAPI {
|
class MatchesAPI {
|
||||||
|
|
||||||
func fetchMatches(for game: String) -> [Match]? {
|
func fetchMatches(for game: String) -> [Match]? {
|
||||||
@@ -26,13 +22,9 @@ class MatchesAPI {
|
|||||||
|
|
||||||
private func fetchData(for game: String) -> String? {
|
private func fetchData(for game: String) -> String? {
|
||||||
let url = constructURL(for: game)
|
let url = constructURL(for: game)
|
||||||
// DispatchQueue.global().async { [unowned self] in
|
if let data = try? String(contentsOf: url) {
|
||||||
if let url = URL(string: url) {
|
return data
|
||||||
if let data = try? String(contentsOf: url) {
|
}
|
||||||
return data
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// }
|
|
||||||
return nil
|
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 baseURL = "https://liquipedia.net/"
|
||||||
let query = "/api.php?action=parse&page=Liquipedia:Upcoming_and_ongoing_matches&format=json&prop=text"
|
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
|
import Cocoa
|
||||||
|
|
||||||
class StatusBarController: NSObject, NSMenuItemValidation {
|
class StatusBarController: NSObject, NSMenuItemValidation {
|
||||||
|
|
||||||
func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
|
func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
let statusBar = NSMenu()
|
let statusBar = NSMenu()
|
||||||
let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
|
let statusBarItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
|
||||||
let matchesAPI = MatchesAPI()
|
let matchesAPI = MatchesAPI()
|
||||||
var matches = [Match]()
|
var matches = [Match]()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user