Skip to content

Commit 6a1087f

Browse files
authored
Merge pull request #4538 from EdgeApp/jon/fix/asset-stataus-appversion
Support version-specific targeting of AssetStatus messages
2 parents b4d68dd + e619beb commit 6a1087f

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
"edge-currency-monero": "^1.1.1",
144144
"edge-currency-plugins": "^2.3.0",
145145
"edge-exchange-plugins": "^0.21.11",
146-
"edge-info-server": "^1.0.1",
146+
"edge-info-server": "^1.0.2",
147147
"edge-login-ui-rn": "^2.14.1",
148148
"ethers": "^5.6.0",
149149
"paraswap": "^5.2.0",

src/components/scenes/TransactionListScene.tsx

+16-8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { EdgeCurrencyWallet, EdgeTokenMap, EdgeTransaction } from 'edge-core-js'
55
import { asAssetStatus, AssetStatus } from 'edge-info-server/types'
66
import * as React from 'react'
77
import { RefreshControl } from 'react-native'
8+
import { getVersion } from 'react-native-device-info'
89

910
import { SPECIAL_CURRENCY_INFO } from '../../constants/WalletAndCurrencyConstants'
1011
import { useHandler } from '../../hooks/useHandler'
@@ -52,7 +53,7 @@ function TransactionListComponent(props: Props) {
5253
const flashList = React.useRef<FlashList<ListItem>>(null)
5354
const [searching, setSearching] = React.useState(false)
5455
const [searchText, setSearchText] = React.useState('')
55-
const [assetStatuses, setAssetStatuses] = React.useState<AssetStatus[]>()
56+
const [assetStatuses, setAssetStatuses] = React.useState<AssetStatus[]>([])
5657

5758
// Selectors:
5859
const exchangeDenom = useSelector(state => getExchangeDenomination(state, pluginId, currencyCode))
@@ -146,7 +147,16 @@ function TransactionListComponent(props: Props) {
146147
React.useEffect(() => {
147148
fetchInfo(`v1/assetStatus/${pluginId}${tokenId == null ? '' : `_${tokenId}`}`)
148149
.then(async res => {
149-
setAssetStatuses(asArray(asAssetStatus)(await res.json()))
150+
const allAssetStatuses: AssetStatus[] = asArray(asAssetStatus)(await res.json())
151+
const version = getVersion()
152+
153+
// Filter for assetStatuses relevant to this instance of the app
154+
setAssetStatuses(
155+
allAssetStatuses.filter(assetStatus => {
156+
const { appId, appVersions } = assetStatus
157+
return (appId == null || appId === config.appId) && (appVersions == null || appVersions.includes(version))
158+
})
159+
)
150160
})
151161
.catch(console.error)
152162
}, [pluginId, tokenId])
@@ -178,12 +188,10 @@ function TransactionListComponent(props: Props) {
178188
onSearchingChange={setSearching}
179189
onSearchTextChange={setSearchText}
180190
/>
181-
{assetStatuses != null && assetStatuses.length > 0
182-
? assetStatuses.map(assetStatus =>
183-
assetStatus.appId == null || assetStatus.appId === config.appId ? (
184-
<AssetStatusCard assetStatus={assetStatus} key={`${String(assetStatus.localeStatusTitle)}-${String(assetStatus.localeStatusBody)}`} />
185-
) : null
186-
)
191+
{assetStatuses.length > 0
192+
? assetStatuses.map(assetStatus => (
193+
<AssetStatusCard assetStatus={assetStatus} key={`${String(assetStatus.localeStatusTitle)}-${String(assetStatus.localeStatusBody)}`} />
194+
))
187195
: null}
188196
</>
189197
)

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -7774,10 +7774,10 @@ edge-exchange-plugins@^0.21.11:
77747774
utf8 "^3.0.0"
77757775
xrpl "^2.10.0"
77767776

7777-
edge-info-server@^1.0.1:
7778-
version "1.0.1"
7779-
resolved "https://registry.yarnpkg.com/edge-info-server/-/edge-info-server-1.0.1.tgz#3cdb4c8e017fd3a674a145264291cb81d78ec404"
7780-
integrity sha512-/CrEQ7eSCOkPuFhrOGQm304WvyRQsrvgKIQSCMEjoiEO9yL83S5fTCrcbwDj5LY2t+fhRp5bKwXNlo2xOqzVJQ==
7777+
edge-info-server@^1.0.2:
7778+
version "1.0.2"
7779+
resolved "https://registry.yarnpkg.com/edge-info-server/-/edge-info-server-1.0.2.tgz#7454683a8c4e56cbcbb0e97aa7d6651c3f73f833"
7780+
integrity sha512-jtXuLLXsIf8Fmgq1maZ64Pt2lzjfSkgA/CTDRQ8i2tzOjci7JwYxsOKCf2gW6OOdoSovvFdJwWHNJvEldCDZbw==
77817781
dependencies:
77827782
cleaners "^0.3.16"
77837783

0 commit comments

Comments
 (0)