Skip to content

Commit

Permalink
Comment out new ScamWarning
Browse files Browse the repository at this point in the history
Pending further refinement
  • Loading branch information
Jon-edge committed May 30, 2024
1 parent ae572ed commit 458e82e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 43 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

- added: Add Visa/MC buy support with Paybis
- added: Support for `promoId`-based filtering for Promo Cards
- added: Scam warning to the first login after app install, first view of private keys, and first use of WalletConnect
- added: New Asset Setting to manually enable tokens with detected balances across all wallets
- added: MUTE_CONSOLE_OUTPUT environment variable to disable specific console output functions
- added: Performance logging with app start-up time and login time as initial performance metrics
Expand Down
79 changes: 37 additions & 42 deletions src/actions/ScamWarningActions.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import { asBoolean, asObject, asOptional } from 'cleaners'
import { Disklet, makeReactNativeDisklet } from 'disklet'
import { Disklet } from 'disklet'
import * as React from 'react'
import { AirshipBridge } from 'react-native-airship'
import { sprintf } from 'sprintf-js'

import { ConfirmContinueModal } from '../components/modals/ConfirmContinueModal'
import { ScamWarningModal } from '../components/modals/ScamWarningModal'
import { Airship } from '../components/services/AirshipInstance'
import { Paragraph, WarningText } from '../components/themed/EdgeText'
import { SCAM_WARNING, SCAM_WARNING_2 } from '../constants/constantSettings'
import { SCAM_WARNING } from '../constants/constantSettings'
import { lstrings } from '../locales/strings'
import { config } from '../theme/appConfig'
import { getFirstOpenInfo } from './FirstOpenActions'

let isSendScamWarningChecked = false

Expand Down Expand Up @@ -42,37 +39,37 @@ export const showSendScamWarningModal = async (disklet: Disklet) => {
}
}

const scamWarningDisklet = makeReactNativeDisklet()
// const scamWarningDisklet = makeReactNativeDisklet()
const asScamWarningInfo = asObject({
firstPrivateKeyView: asOptional(asBoolean, true),
firstWalletConnect: asOptional(asBoolean, true),
firstLogin: asOptional(asBoolean, true)
})
type ScamWarningInfo = ReturnType<typeof asScamWarningInfo>
let scamWarningInfo: ScamWarningInfo
// let scamWarningInfo: ScamWarningInfo

const getScamWarningInfo = async (): Promise<ScamWarningInfo> => {
if (scamWarningInfo == null) {
try {
const scamWarningText = await scamWarningDisklet.getText(SCAM_WARNING_2)
scamWarningInfo = asScamWarningInfo(JSON.parse(scamWarningText))
} catch (error: any) {
if ((await getFirstOpenInfo()).isFirstOpen === 'false') {
// If this isn't the first open, don't pester the user with new scam
// warnings. Assume this isn't their first rodeo across the board.
scamWarningInfo = {
firstPrivateKeyView: false,
firstWalletConnect: false,
firstLogin: false
}
} else {
scamWarningInfo = asScamWarningInfo({})
}
await scamWarningDisklet.setText(SCAM_WARNING_2, JSON.stringify(scamWarningInfo))
}
}
return scamWarningInfo
}
// const getScamWarningInfo = async (): Promise<ScamWarningInfo> => {
// if (scamWarningInfo == null) {
// try {
// const scamWarningText = await scamWarningDisklet.getText(SCAM_WARNING_2)
// scamWarningInfo = asScamWarningInfo(JSON.parse(scamWarningText))
// } catch (error: any) {
// if ((await getFirstOpenInfo()).isFirstOpen === 'false') {
// // If this isn't the first open, don't pester the user with new scam
// // warnings. Assume this isn't their first rodeo across the board.
// scamWarningInfo = {
// firstPrivateKeyView: false,
// firstWalletConnect: false,
// firstLogin: false
// }
// } else {
// scamWarningInfo = asScamWarningInfo({})
// }
// await scamWarningDisklet.setText(SCAM_WARNING_2, JSON.stringify(scamWarningInfo))
// }
// }
// return scamWarningInfo
// }

/**
* Warning the user about bad actors that are walking the user through
Expand All @@ -83,17 +80,15 @@ const getScamWarningInfo = async (): Promise<ScamWarningInfo> => {
* dangerous action.
**/
export const showScamWarningModal = async (scamWarningInfoKey: keyof ScamWarningInfo) => {
const scamWarningInfo = await getScamWarningInfo()

// Ignore if we've already triggered a particular warning
if (scamWarningInfo[scamWarningInfoKey]) {
// Make sure we don't show this warning again for this particular scenario
scamWarningInfo[scamWarningInfoKey] = false
await scamWarningDisklet.setText(SCAM_WARNING_2, JSON.stringify(scamWarningInfo))

// Show the scam warning modal
await Airship.show((bridge: AirshipBridge<'yes' | 'no' | undefined>) => {
return <ScamWarningModal bridge={bridge} />
})
}
// const scamWarningInfo = await getScamWarningInfo()
// // Ignore if we've already triggered a particular warning
// if (scamWarningInfo[scamWarningInfoKey]) {
// // Make sure we don't show this warning again for this particular scenario
// scamWarningInfo[scamWarningInfoKey] = false
// await scamWarningDisklet.setText(SCAM_WARNING_2, JSON.stringify(scamWarningInfo))
// // Show the scam warning modal
// await Airship.show((bridge: AirshipBridge<'yes' | 'no' | undefined>) => {
// return <ScamWarningModal bridge={bridge} />
// })
// }
}

0 comments on commit 458e82e

Please sign in to comment.