diff --git a/BlackCandy.xcodeproj/project.pbxproj b/BlackCandy.xcodeproj/project.pbxproj index 8023541..7c5c7d9 100644 --- a/BlackCandy.xcodeproj/project.pbxproj +++ b/BlackCandy.xcodeproj/project.pbxproj @@ -18,6 +18,7 @@ 641B5D942A12080300ECA220 /* LiveJSONDataClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 641B5D932A12080300ECA220 /* LiveJSONDataClient.swift */; }; 641B5D962A1209C000ECA220 /* LivePlayerClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 641B5D952A1209C000ECA220 /* LivePlayerClient.swift */; }; 641B5D982A120B9800ECA220 /* LiveNowPlayingClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 641B5D972A120B9800ECA220 /* LiveNowPlayingClient.swift */; }; + 6426B5CF2AFD1EFF00EEDA3D /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6426B5CE2AFD1EFF00EEDA3D /* Constants.swift */; }; 642B04ED2A02376400EEF844 /* CookiesClientTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 642B04EC2A02376400EEF844 /* CookiesClientTests.swift */; }; 6431DDF02963D0240013F135 /* PlayerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6431DDEF2963D0240013F135 /* PlayerViewController.swift */; }; 6431DDF82964167E0013F135 /* NotificationName.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6431DDF72964167E0013F135 /* NotificationName.swift */; }; @@ -141,6 +142,7 @@ 641B5D932A12080300ECA220 /* LiveJSONDataClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LiveJSONDataClient.swift; sourceTree = ""; }; 641B5D952A1209C000ECA220 /* LivePlayerClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LivePlayerClient.swift; sourceTree = ""; }; 641B5D972A120B9800ECA220 /* LiveNowPlayingClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LiveNowPlayingClient.swift; sourceTree = ""; }; + 6426B5CE2AFD1EFF00EEDA3D /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = ""; }; 642B04EC2A02376400EEF844 /* CookiesClientTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CookiesClientTests.swift; sourceTree = ""; }; 6431DDEF2963D0240013F135 /* PlayerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerViewController.swift; sourceTree = ""; }; 6431DDF72964167E0013F135 /* NotificationName.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationName.swift; sourceTree = ""; }; @@ -565,6 +567,7 @@ DD7671C5290B6E1600F92825 /* AudioSessionControl.swift */, DD7671C8290B76AE00F92825 /* RemoteControl.swift */, 6431DDF72964167E0013F135 /* NotificationName.swift */, + 6426B5CE2AFD1EFF00EEDA3D /* Constants.swift */, ); path = Utils; sourceTree = ""; @@ -798,6 +801,7 @@ DD18369327CC9FF60018ECF5 /* TurboSession.swift in Sources */, DDE710EE28D05DED00CE7494 /* PlayerPlaylistView.swift in Sources */, DD7671C9290B76AE00F92825 /* RemoteControl.swift in Sources */, + 6426B5CF2AFD1EFF00EEDA3D /* Constants.swift in Sources */, 6431DDF82964167E0013F135 /* NotificationName.swift in Sources */, DD4D05A328BDE7810035D26D /* User.swift in Sources */, DD751E0E2888F19100B8128E /* CookiesClient.swift in Sources */, diff --git a/BlackCandy/Clients/APIClient/LiveAPIClient.swift b/BlackCandy/Clients/APIClient/LiveAPIClient.swift index 4232dcf..a546496 100644 --- a/BlackCandy/Clients/APIClient/LiveAPIClient.swift +++ b/BlackCandy/Clients/APIClient/LiveAPIClient.swift @@ -9,7 +9,7 @@ extension APIClient: DependencyKey { var headers: HTTPHeaders { var basicHeaders: HTTPHeaders = [ - .userAgent(userDefaultClient.userAgent) + .userAgent(BLACK_CANDY_USER_AGENT) ] if let token = keychainClient.apiToken() { diff --git a/BlackCandy/Clients/PlayerClient/LivePlayerClient.swift b/BlackCandy/Clients/PlayerClient/LivePlayerClient.swift index 9a189c3..15d035f 100644 --- a/BlackCandy/Clients/PlayerClient/LivePlayerClient.swift +++ b/BlackCandy/Clients/PlayerClient/LivePlayerClient.swift @@ -5,7 +5,6 @@ import AVFoundation extension PlayerClient: DependencyKey { static func live(player: AVPlayer) -> Self { @Dependency(\.keychainClient) var keychainClient - @Dependency(\.userDefaultsClient) var userDefaultClient let apiToken = keychainClient.apiToken() ?? "" @@ -18,7 +17,7 @@ extension PlayerClient: DependencyKey { let asset = AVURLAsset(url: songUrl, options: [ "AVURLAssetHTTPHeaderFieldsKey": [ "Authorization": "Token \(apiToken)", - "User-Agent": userDefaultClient.userAgent + "User-Agent": BLACK_CANDY_USER_AGENT ] ]) diff --git a/BlackCandy/Clients/UserDefaultsClient/UserDefaultsClient.swift b/BlackCandy/Clients/UserDefaultsClient/UserDefaultsClient.swift index 12d6251..9bf7999 100644 --- a/BlackCandy/Clients/UserDefaultsClient/UserDefaultsClient.swift +++ b/BlackCandy/Clients/UserDefaultsClient/UserDefaultsClient.swift @@ -2,7 +2,6 @@ import Foundation import Dependencies struct UserDefaultsClient { - let userAgent = "Black Candy iOS" var serverAddress: () -> URL? var updateServerAddress: (URL?) -> Void } diff --git a/BlackCandy/Turbo/TurboSession.swift b/BlackCandy/Turbo/TurboSession.swift index ef5d476..c1a2930 100644 --- a/BlackCandy/Turbo/TurboSession.swift +++ b/BlackCandy/Turbo/TurboSession.swift @@ -6,15 +6,13 @@ struct TurboSession { static let processPool = WKProcessPool() static func create(store: StoreOf) -> Session { - @Dependency(\.userDefaultsClient) var userDefaultClient - let configuration = WKWebViewConfiguration() let scriptMessageHandler = TurboScriptMessageHandler(store: store) let pathConfiguration = PathConfiguration(sources: [ .file(Bundle.main.url(forResource: "path-configuration", withExtension: "json")!) ]) - configuration.applicationNameForUserAgent = userDefaultClient.userAgent + configuration.applicationNameForUserAgent = BLACK_CANDY_USER_AGENT configuration.processPool = TurboSession.processPool configuration.userContentController.add(scriptMessageHandler, name: "nativeApp") diff --git a/BlackCandy/Utils/Constants.swift b/BlackCandy/Utils/Constants.swift new file mode 100644 index 0000000..297769c --- /dev/null +++ b/BlackCandy/Utils/Constants.swift @@ -0,0 +1,3 @@ +import Foundation + +let BLACK_CANDY_USER_AGENT = "Black Candy iOS"