Skip to content

Commit

Permalink
Remove user agent property from UserDefaultsClient
Browse files Browse the repository at this point in the history
  • Loading branch information
aidewoode committed Nov 9, 2023
1 parent 9f888bc commit ef4a7a5
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
4 changes: 4 additions & 0 deletions BlackCandy.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -141,6 +142,7 @@
641B5D932A12080300ECA220 /* LiveJSONDataClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LiveJSONDataClient.swift; sourceTree = "<group>"; };
641B5D952A1209C000ECA220 /* LivePlayerClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LivePlayerClient.swift; sourceTree = "<group>"; };
641B5D972A120B9800ECA220 /* LiveNowPlayingClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LiveNowPlayingClient.swift; sourceTree = "<group>"; };
6426B5CE2AFD1EFF00EEDA3D /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
642B04EC2A02376400EEF844 /* CookiesClientTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CookiesClientTests.swift; sourceTree = "<group>"; };
6431DDEF2963D0240013F135 /* PlayerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerViewController.swift; sourceTree = "<group>"; };
6431DDF72964167E0013F135 /* NotificationName.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationName.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -565,6 +567,7 @@
DD7671C5290B6E1600F92825 /* AudioSessionControl.swift */,
DD7671C8290B76AE00F92825 /* RemoteControl.swift */,
6431DDF72964167E0013F135 /* NotificationName.swift */,
6426B5CE2AFD1EFF00EEDA3D /* Constants.swift */,
);
path = Utils;
sourceTree = "<group>";
Expand Down Expand Up @@ -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 */,
Expand Down
2 changes: 1 addition & 1 deletion BlackCandy/Clients/APIClient/LiveAPIClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
3 changes: 1 addition & 2 deletions BlackCandy/Clients/PlayerClient/LivePlayerClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() ?? ""

Expand All @@ -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
]
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Foundation
import Dependencies

struct UserDefaultsClient {
let userAgent = "Black Candy iOS"
var serverAddress: () -> URL?
var updateServerAddress: (URL?) -> Void
}
Expand Down
4 changes: 1 addition & 3 deletions BlackCandy/Turbo/TurboSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ struct TurboSession {
static let processPool = WKProcessPool()

static func create(store: StoreOf<AppReducer>) -> 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")

Expand Down
3 changes: 3 additions & 0 deletions BlackCandy/Utils/Constants.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Foundation

let BLACK_CANDY_USER_AGENT = "Black Candy iOS"

0 comments on commit ef4a7a5

Please sign in to comment.