mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-18 07:28:28 +02:00
Feature/2581 permalinks
This commit is contained in:
@@ -24,8 +24,19 @@ import Foundation
|
||||
private let serverUrlKey = "serverURL"
|
||||
private let pusherUrlKey = "pusherURL"
|
||||
private let flavorUrlKey = "flavor"
|
||||
private let nameKey = "name"
|
||||
private let permalinkKey = "permalink"
|
||||
|
||||
var serverURLs = Array<ServerURLs>()
|
||||
var serverSettings = Array<ServerSetting>()
|
||||
|
||||
var selectedIndex: Int {
|
||||
get {
|
||||
return UserDefaults.standard.integer(forKey: "Bwi_Server_Url_Helper_Index")
|
||||
}
|
||||
set(newSelectedIndex) {
|
||||
UserDefaults.standard.set(newSelectedIndex, forKey: "Bwi_Server_Url_Helper_Index")
|
||||
}
|
||||
}
|
||||
|
||||
private func loadURLs() {
|
||||
if let path = Bundle.main.path(forResource: "serverurls", ofType: "json") {
|
||||
@@ -36,11 +47,14 @@ import Foundation
|
||||
|
||||
for urlSet in urls {
|
||||
if let dict = urlSet as? Dictionary<String,String> {
|
||||
if let server = dict[serverUrlKey], let pusher = dict[pusherUrlKey], let flavor = dict[flavorUrlKey] {
|
||||
serverURLs.append(ServerURLs(serverUrl: server, pusherUrl: pusher, flavor: flavor))
|
||||
if let server = dict[serverUrlKey],
|
||||
let pusher = dict[pusherUrlKey],
|
||||
let flavor = dict[flavorUrlKey],
|
||||
let name = dict[nameKey],
|
||||
let permalink = dict[permalinkKey] {
|
||||
serverSettings.append(ServerSetting(name:name, serverUrl: server, pusherUrl: pusher, flavor: flavor, permalink:permalink))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
@@ -55,24 +69,48 @@ import Foundation
|
||||
}
|
||||
|
||||
func serverUrl() -> String? {
|
||||
if serverURLs.count > 0 {
|
||||
return serverURLs[0].serverUrl
|
||||
if serverSettings.indices.contains(selectedIndex) {
|
||||
return serverSettings[selectedIndex].serverUrl
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func pusherUrl() -> String? {
|
||||
if serverURLs.count > 0 {
|
||||
return serverURLs[0].pusherUrl
|
||||
if serverSettings.indices.contains(selectedIndex) {
|
||||
return serverSettings[selectedIndex].pusherUrl
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func flavor() -> String? {
|
||||
if serverURLs.count > 0 {
|
||||
return serverURLs[0].flavor
|
||||
if serverSettings.indices.contains(selectedIndex) {
|
||||
return serverSettings[selectedIndex].flavor
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func name() -> String? {
|
||||
if serverSettings.indices.contains(selectedIndex) {
|
||||
return serverSettings[selectedIndex].name
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func permalink() -> String? {
|
||||
if serverSettings.indices.contains(selectedIndex) {
|
||||
return serverSettings[selectedIndex].permalink
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func httpsPermalink() -> String? {
|
||||
if serverSettings.indices.contains(selectedIndex) {
|
||||
return "https://" + serverSettings[selectedIndex].permalink
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user