mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
refactor anisette manager to own file
Signed-off-by: Joseph Mattello <mail@joemattiello.com>
This commit is contained in:
@@ -13,34 +13,6 @@ import minimuxer
|
||||
|
||||
import AltStoreCore
|
||||
import UniformTypeIdentifiers
|
||||
import OSLog
|
||||
|
||||
public struct AnisetteManager {
|
||||
|
||||
/// User defined URL from Settings/UserDefaults
|
||||
static var userURL: String? {
|
||||
guard let urlString = UserDefaults.shared.customAnisetteURL else { return nil }
|
||||
// Test it's a valid URL
|
||||
guard URL(string: urlString) != nil else {
|
||||
ELOG("UserDefaults has invalid `customAnisetteURL`")
|
||||
assertionFailure("UserDefaults has invalid `customAnisetteURL`")
|
||||
return nil
|
||||
}
|
||||
return urlString
|
||||
}
|
||||
static var defaultURL: String {
|
||||
guard let url = Bundle.main.object(forInfoDictionaryKey: "ALTAnisetteURL") as? String else {
|
||||
assertionFailure("Info.plist has invalid `ALTAnisetteURL`")
|
||||
abort()
|
||||
}
|
||||
return url
|
||||
}
|
||||
static var currentURLString: String { userURL ?? defaultURL }
|
||||
// Force unwrap is safe here since we check validity before hand -- @JoeMatt
|
||||
|
||||
/// User url or default from plist if none specified
|
||||
static var currentURL: URL { URL(string: currentURLString)! }
|
||||
}
|
||||
|
||||
class LaunchViewController: RSTLaunchViewController, UIDocumentPickerDelegate
|
||||
{
|
||||
|
||||
36
AltStore/Settings/AnisetteManager.swift
Normal file
36
AltStore/Settings/AnisetteManager.swift
Normal file
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// AnisetteManager.swift
|
||||
// SideStore
|
||||
//
|
||||
// Created by Joseph Mattiello on 11/16/22.
|
||||
// Copyright © 2022 SideStore. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public struct AnisetteManager {
|
||||
|
||||
/// User defined URL from Settings/UserDefaults
|
||||
static var userURL: String? {
|
||||
guard let urlString = UserDefaults.shared.customAnisetteURL, !urlString.isEmpty else { return nil }
|
||||
// Test it's a valid URL
|
||||
guard URL(string: urlString) != nil else {
|
||||
ELOG("UserDefaults has invalid `customAnisetteURL`")
|
||||
assertionFailure("UserDefaults has invalid `customAnisetteURL`")
|
||||
return nil
|
||||
}
|
||||
return urlString
|
||||
}
|
||||
static var defaultURL: String {
|
||||
guard let url = Bundle.main.object(forInfoDictionaryKey: "ALTAnisetteURL") as? String else {
|
||||
assertionFailure("Info.plist has invalid `ALTAnisetteURL`")
|
||||
abort()
|
||||
}
|
||||
return url
|
||||
}
|
||||
static var currentURLString: String { userURL ?? defaultURL }
|
||||
// Force unwrap is safe here since we check validity before hand -- @JoeMatt
|
||||
|
||||
/// User url or default from plist if none specified
|
||||
static var currentURL: URL { URL(string: currentURLString)! }
|
||||
}
|
||||
Reference in New Issue
Block a user