Skip to content

Commit 8596b17

Browse files
authored
Merge pull request #5451 from EdgeApp/jon/new-ver-msg
Jon/new-ver-msg
2 parents 757c659 + 8a084e0 commit 8596b17

File tree

9 files changed

+66
-63
lines changed

9 files changed

+66
-63
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased (develop)
44

5+
- added: "Update Available" modal
6+
57
## 4.23.0 (staging)
68

79
- added: Add Abstract ETH Layer 2 support

src/components/modals/UpdateModal.tsx

Lines changed: 0 additions & 61 deletions
This file was deleted.

src/locales/en_US.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,6 +1685,7 @@ const strings = {
16851685
notifications_recent: 'Recent',
16861686
notifications_none: `You're all caught up!`,
16871687
swap: 'Swap',
1688+
update_available: 'Update Available',
16881689

16891690
// Currency Labels
16901691
currency_label_AFN: 'Afghani',

src/locales/strings/enUS.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,6 +1455,7 @@
14551455
"notifications_recent": "Recent",
14561456
"notifications_none": "You're all caught up!",
14571457
"swap": "Swap",
1458+
"update_available": "Update Available",
14581459
"currency_label_AFN": "Afghani",
14591460
"currency_label_ALL": "Lek",
14601461
"currency_label_DZD": "Algerian Dinar",

src/theme/edgeConfig.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const edgeConfig: AppConfig = {
66
appId: undefined,
77
appName: 'Edge',
88
appNameShort: 'Edge',
9-
appStore: 'https://itunes.apple.com/app/id1344400091',
9+
appStore: 'https://apps.apple.com/us/app/edge-crypto-bitcoin-wallet/id1344400091',
1010
backupAccountSite: 'https://edge.app/light-account-creation/',
1111
configName: 'edge',
1212
darkTheme: edgeDark,
@@ -23,6 +23,7 @@ export const edgeConfig: AppConfig = {
2323
lightTheme: edgeLight,
2424
notificationServers: ['https://push2.edge.app'],
2525
phoneNumber: '+1-619-777-5688',
26+
playStore: 'https://play.google.com/store/apps/details?id=co.edgesecure.app&hl=en_US',
2627
referralServers: ['https://referral1.edge.app'],
2728
supportsEdgeLogin: true,
2829
supportEmail: '[email protected]',

src/theme/testConfig.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const testConfig: AppConfig = {
66
appId: 'com.testy.wallet',
77
appName: 'Testy Wallet',
88
appNameShort: 'Testy',
9-
appStore: 'https://itunes.apple.com/app/id1344400092',
9+
appStore: 'https://apps.apple.com/us/app/edge-crypto-bitcoin-wallet/id1344400091',
1010
backupAccountSite: 'https://support.testy.com/accountbackupinfo',
1111
configName: 'test',
1212
darkTheme: testDark,
@@ -24,6 +24,7 @@ export const testConfig: AppConfig = {
2424
lightTheme: testLight,
2525
notificationServers: ['https://push2.edge.app'],
2626
phoneNumber: '+1-800-100-1000',
27+
playStore: 'https://play.google.com/store/apps/details?id=co.edgesecure.app&hl=en_US',
2728
referralServers: ['https://referral1.testy.com'],
2829
supportsEdgeLogin: false,
2930
supportEmail: '[email protected]',

src/types/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ export interface AppConfig {
334334
lightTheme: Theme
335335
notificationServers: string[]
336336
phoneNumber: string
337+
playStore: string
337338
referralServers?: string[]
338339
supportsEdgeLogin: boolean
339340
supportEmail: string

src/util/network.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { getVersion } from 'react-native-device-info'
66

77
import { config } from '../theme/appConfig'
88
import { asyncWaterfall, getOsVersion, shuffleArray } from './utils'
9+
import { checkAppVersion } from './versionCheck'
910
const INFO_SERVERS = ['https://info1.edge.app', 'https://info2.edge.app']
1011
const RATES_SERVERS = ['https://rates1.edge.app', 'https://rates2.edge.app']
1112

@@ -87,6 +88,7 @@ export const initInfoServer = async () => {
8788
} else {
8889
const infoData = await response.json()
8990
infoServerData.rollup = asInfoRollup(infoData)
91+
await checkAppVersion()
9092
}
9193
} catch (e) {
9294
console.warn('initInfoServer: Failed to ping info server')

src/util/versionCheck.tsx

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import * as React from 'react'
2+
import { Linking, Platform } from 'react-native'
3+
import { getVersion } from 'react-native-device-info'
4+
5+
import { ButtonsModal } from '../components/modals/ButtonsModal'
6+
import { Airship } from '../components/services/AirshipInstance'
7+
import { getLocaleOrDefaultString } from '../locales/intl'
8+
import { lstrings } from '../locales/strings'
9+
import { config } from '../theme/appConfig'
10+
import { infoServerData } from './network'
11+
12+
const compareVersions = (v1: string, v2: string): number => {
13+
const v1Parts = v1.split('-')[0].split('.').map(Number)
14+
const v2Parts = v2.split('-')[0].split('.').map(Number)
15+
16+
for (let i = 0; i < 3; i++) {
17+
if (v1Parts[i] > v2Parts[i]) return 1
18+
if (v1Parts[i] < v2Parts[i]) return -1
19+
}
20+
return 0
21+
}
22+
23+
export const checkAppVersion = async (): Promise<void> => {
24+
const currentVersion = getVersion()
25+
const platform = Platform.OS
26+
27+
// Get latest version from info server
28+
const updateInfo = infoServerData.rollup?.updateInfo
29+
if (updateInfo == null || updateInfo[platform] == null) return
30+
const { updateVersion, localeMessage } = updateInfo[platform]
31+
32+
const message = getLocaleOrDefaultString(localeMessage)
33+
34+
// Compare versions
35+
if (compareVersions(updateVersion, currentVersion) > 0) {
36+
// Show update modal
37+
const updateRes = await Airship.show<'update' | undefined>(bridge => (
38+
<ButtonsModal
39+
bridge={bridge}
40+
title={lstrings.update_available}
41+
message={message}
42+
buttons={{
43+
update: {
44+
label: lstrings.update_now,
45+
type: 'primary'
46+
}
47+
}}
48+
/>
49+
))
50+
if (updateRes === 'update') {
51+
const url = Platform.OS === 'android' ? config.playStore : config.appStore
52+
await Linking.openURL(url)
53+
}
54+
}
55+
}

0 commit comments

Comments
 (0)