Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the issue of release build not getting the feature flag values #40

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions dydx/dydxFormatter/dydxFormatter/_Utils/dydxFeatureFlag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ public enum dydxBoolFeatureFlag: String, CaseIterable {
private static let obj = NSObject()

public var isEnabled: Bool {
Self.obj.parser.asBoolean(FeatureService.shared?.flag(feature: rawValue))?.boolValue ?? false
if FeatureService.shared == nil {
Console.shared.log("WARNING: FeatureService not yet set up.")
}
return Self.obj.parser.asBoolean(FeatureService.shared?.flag(feature: rawValue))?.boolValue ?? false
}

public static var enabledFlags: [String] {
Expand All @@ -35,7 +38,10 @@ public enum dydxStringFeatureFlag: String {
private static let obj = NSObject()

public var string: String? {
Self.obj.parser.asString(FeatureService.shared?.flag(feature: rawValue))
if FeatureService.shared == nil {
Console.shared.log("WARNING: FeatureService not yet set up.")
}
return Self.obj.parser.asString(FeatureService.shared?.flag(feature: rawValue))
}
}

Expand All @@ -45,6 +51,9 @@ public enum dydxNumberFeatureFlag: String {
private static let obj = NSObject()

public var number: NSNumber? {
Self.obj.parser.asNumber(FeatureService.shared?.flag(feature: rawValue))
if FeatureService.shared == nil {
Console.shared.log("WARNING: FeatureService not yet set up.")
}
return Self.obj.parser.asNumber(FeatureService.shared?.flag(feature: rawValue))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import Cartera

final class dydxCarteraConfigWorker: BaseWorker {

override init() {
public override func start() {
super.start()

let filePath = "configs/wallets.json"
#if DEBUG
let url: String? = nil
Expand All @@ -26,10 +28,6 @@ final class dydxCarteraConfigWorker: BaseWorker {
CarteraConfig.shared.registerWallets(configJsonData: walletJson)
}
}
}

public override func start() {
super.start()

AbacusStateManager.shared.$currentEnvironment
.removeDuplicates()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private class dydxUpdateViewPresenter: HostedViewPresenter<dydxUpdateViewModel>,

viewModel = dydxUpdateViewModel()
}

override func start() {
super.start()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import dydxFormatter
public final class AbacusStateManager: NSObject {
public static let shared = AbacusStateManager()

public let deploymentUri = {
public lazy var deploymentUri: String = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add a private (set) here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh.. lazy var should be readonly already.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without private set, it is not read only

https://stackoverflow.com/a/26048425

// "lazy var" because FeatureService.shared needs be assigned first
let url = dydxStringFeatureFlag.deployment_url.string ?? (CredientialConfig.shared.key(for: "webAppUrl"))!
return url.last == "/" ? url : url + "/"
}()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class dydxFAQViewModel: PlatformViewModel {
.themeFont(fontType: .text, fontSize: .small)
.themeColor(foreground: .textSecondary)
Spacer(minLength: 16)
//PlatformIconViewModel behaves weirdly here. When isExpanded is toggled, sometimes the icon hides entirely. Do not use.
// PlatformIconViewModel behaves weirdly here. When isExpanded is toggled, sometimes the icon hides entirely. Do not use.
Image(self.isExpanded ? "icon_collapse" : "icon_expand", bundle: .dydxView)
.frame(width: hideShowImageDiameter, height: hideShowImageDiameter)
.padding(.all, paddingDim)
Expand Down
Loading