Skip to content

Commit

Permalink
pipe in expiresAt and support email
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-dydx committed May 29, 2024
1 parent d82e8e1 commit c656b21
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,42 +24,38 @@ public final class dydxRestrictionsWorker: BaseWorker {
}
.store(in: &subscriptions)

// used in protocol 4.0
AbacusStateManager.shared.state.complianceStatus
.sink { complianceStatus in
Self.handle(complianceStatus: complianceStatus)
// used in protocol 5.0
AbacusStateManager.shared.state.compliance
.sink { compliance in
Self.handle(compliance: compliance)
}
.store(in: &subscriptions)
}

public static func handle(complianceStatus: ComplianceStatus) {
public static func handle(compliance: Compliance) {
let title: String?
let body: String?
switch complianceStatus {
switch compliance.status {
case .compliant:
return
case .firstStrike, .firstStrikeCloseOnly, .closeOnly:
// TODO: add DATE & EMAIL
// [MOB-478 : update copy params for new compliance status strings](https://linear.app/dydx/issue/MOB-478/update-copy-params-for-new-compliance-status-strings)
title = DataLocalizer.shared?.localize(
path: "APP.COMPLIANCE.CLOSE_ONLY_TITLE",
params: nil) ?? ""
body = DataLocalizer.shared?.localize(
path: "APP.COMPLIANCE.CLOSE_ONLY_BODY",
params: [
"DATE": "--",
"EMAIL": "--"
"DATE": compliance.expiresAt ?? "--",
"EMAIL": AbacusStateManager.shared.environment?.links?.complianceSupportEmail ?? "--"
]) ?? ""
case .blocked:
// TODO: add DATE & EMAIL
// [MOB-478 : update copy params for new compliance status strings](https://linear.app/dydx/issue/MOB-478/update-copy-params-for-new-compliance-status-strings)
title = DataLocalizer.shared?.localize(
path: "APP.COMPLIANCE.PERMANENTLY_BLOCKED_TITLE",
params: nil) ?? ""
body = DataLocalizer.shared?.localize(
path: "APP.COMPLIANCE.PERMANENTLY_BLOCKED_BODY",
params: [
"EMAIL": "--"
"EMAIL": AbacusStateManager.shared.environment?.links?.complianceSupportEmail ?? "--"
]) ?? ""
default:
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ public final class AbacusState {
}

// protocol v5.0 and up
public var complianceStatus: AnyPublisher<ComplianceStatus, Never> {
public var compliance: AnyPublisher<Compliance, Never> {
statePublisher
.compactMap { $0?.compliance?.status }
.compactMap { $0?.compliance }
.removeDuplicates()
.share()
.eraseToAnyPublisher()
Expand Down

0 comments on commit c656b21

Please sign in to comment.