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

[7] fix(tokens): fix tokens list loading state #3201

Merged
Merged
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
840af3f
fix: fix tokens list loading state
shoom3301 Oct 10, 2023
d1f8851
fix: fix token store updating inconsistency
shoom3301 Oct 10, 2023
70b87f9
chore: move DEFAULT_FAVOURITE_TOKENS to separate file
shoom3301 Oct 10, 2023
58b890f
refactor: refactor useSearchToken() hook
shoom3301 Oct 10, 2023
614feea
chore: fix tokens lib exports
shoom3301 Oct 10, 2023
b5c1508
chore: refactor TokensListsUpdater
shoom3301 Oct 10, 2023
c3cc4a8
fix: remove duplicates from token search results
shoom3301 Oct 10, 2023
e1626e7
fix(tokens): fix lists toggling
shoom3301 Oct 10, 2023
16ef0a0
fix(tokens): fix list importing
shoom3301 Oct 10, 2023
2a8d3d7
refactor(tokens): refactor tokens state
shoom3301 Oct 11, 2023
d8e4330
Merge branch 'refactor/tokens-remove-legacy' of https://github.com/co…
shoom3301 Oct 11, 2023
7287a63
feat(tokens): lists analytics events
shoom3301 Oct 11, 2023
e7573de
refactor: group and rename entities
shoom3301 Oct 11, 2023
e6be7d3
chore: fix imports
shoom3301 Oct 11, 2023
c684d98
chore: fix cosmos fixtures
shoom3301 Oct 11, 2023
822d170
chore: remove unused code
shoom3301 Oct 11, 2023
9701d07
Merge branch 'refactor/tokens-remove-legacy' of https://github.com/co…
shoom3301 Oct 11, 2023
2592593
chore: fix import
shoom3301 Oct 11, 2023
db8105f
chore: fix typo
shoom3301 Oct 11, 2023
4a28d8c
chore: trim input value
shoom3301 Oct 11, 2023
caeeeb7
chore: fix list removing
shoom3301 Oct 11, 2023
c1ac055
chore: diagrams
shoom3301 Oct 11, 2023
6837b14
refactor: simplify unsupported token hooks
shoom3301 Oct 12, 2023
cc53a88
refactor: simplify useSearchToken
shoom3301 Oct 12, 2023
3127c0e
refactor: rename isTokenAlreadyFoundByAddress
shoom3301 Oct 12, 2023
7370a0b
refactor: use lastUpdateTimeAtom instead of localStorage
shoom3301 Oct 12, 2023
4ab7dbd
chore: remove TOKENS_LISTS_UPDATER_INTERVAL duplicate
shoom3301 Oct 12, 2023
7400345
refactor: use TokenWithLogo.fromToken
shoom3301 Oct 12, 2023
9fc64a1
fix: fix FavouriteTokensList mobile view
shoom3301 Oct 16, 2023
437ca57
fix: fix mobile appearance
shoom3301 Oct 16, 2023
e02d368
fix: select token after import
shoom3301 Oct 16, 2023
45feae5
fix: search token by symbol for autoimporting
shoom3301 Oct 16, 2023
5552b69
feat: add trust as a fallback to logo urls
shoom3301 Oct 16, 2023
734c5f4
refactor: simplify TokenSearchResponse
shoom3301 Oct 16, 2023
20af0e7
chore: docs for complex entities
shoom3301 Oct 16, 2023
c11ac54
chore: cache inputLowerCase
shoom3301 Oct 16, 2023
e1bae58
chore: rename tokenMapToListWithLogo
shoom3301 Oct 16, 2023
cbeaa9b
chore: remove unused files
shoom3301 Oct 17, 2023
010dcb2
feat: reset unsupported tokens periodically
shoom3301 Oct 17, 2023
f07e036
chore: remove excessive files
shoom3301 Oct 17, 2023
34e06de
fix: use token with logo in orders state
shoom3301 Oct 17, 2023
bf7490c
Merge branch 'refactor/tokens-remove-legacy' of https://github.com/co…
shoom3301 Oct 17, 2023
b12a429
refactor: simplify token lists state
shoom3301 Oct 17, 2023
2243394
fix: remove local logos for tokens
shoom3301 Oct 17, 2023
3a8ffc4
chore: fix test
shoom3301 Oct 17, 2023
19e7d6d
chore: change refreshInterval for native balance
shoom3301 Oct 17, 2023
b3cc7ca
refactor: fix press enter handler
shoom3301 Oct 17, 2023
c4cc71e
chore: fix build
shoom3301 Oct 17, 2023
55d2528
chore: fix test
shoom3301 Oct 17, 2023
b2dd6b3
chore: fix text
shoom3301 Oct 17, 2023
099c3bc
chore: fix OrderLogPopupMixData
shoom3301 Oct 17, 2023
2903c28
chore: merge develop
shoom3301 Oct 23, 2023
40c0d9d
chore: fix build
shoom3301 Oct 23, 2023
78dc458
chore: fix build
shoom3301 Oct 23, 2023
b3192bd
chore: fix getTokenLogoFallbacks
shoom3301 Oct 23, 2023
3d28e21
chore: fix lists overriding and search input
shoom3301 Oct 23, 2023
6a7a227
feat: loader for list search
shoom3301 Oct 23, 2023
8602757
chore: fix token logo rounding
shoom3301 Oct 24, 2023
f4af72b
chore: fix tokens sorting
shoom3301 Oct 24, 2023
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
Prev Previous commit
Next Next commit
chore: refactor TokensListsUpdater
  • Loading branch information
shoom3301 committed Oct 10, 2023
commit b5c1508d9f2a9961db038144b487945fce04fe2b
33 changes: 16 additions & 17 deletions libs/tokens/src/updaters/TokensListsUpdater/index.ts
Original file line number Diff line number Diff line change
@@ -29,6 +29,8 @@ const swrOptions: SWRConfiguration = {
revalidateOnFocus: false,
}

const defaultUpdateState: TokensAndListsUpdate = { activeTokens: {}, inactiveTokens: {}, lists: {} }

const LAST_UPDATE_TIME_KEY = (chainId: SupportedChainId) => `tokens-lists-updater:last-update-time[${chainId}]`

export function TokensListsUpdater({ chainId: currentChainId }: { chainId: SupportedChainId }) {
@@ -62,28 +64,25 @@ export function TokensListsUpdater({ chainId: currentChainId }: { chainId: Suppo

if (isLoading || error || !data) return

const { activeTokens, inactiveTokens, lists } = data.reduce<TokensAndListsUpdate>(
(acc, val) => {
const isListEnabled = activeTokensListsMap[val.id]
const { activeTokens, inactiveTokens, lists } = data.reduce<TokensAndListsUpdate>((acc, val) => {
const isListEnabled = activeTokensListsMap[val.id]

acc.lists[val.id] = buildTokenListInfo(val)
acc.lists[val.id] = buildTokenListInfo(val)

val.list.tokens.forEach((token) => {
if (token.chainId === chainId) {
const tokenAddress = token.address.toLowerCase()
val.list.tokens.forEach((token) => {
if (token.chainId === chainId) {
const tokenAddress = token.address.toLowerCase()

if (isListEnabled) {
acc.activeTokens[tokenAddress] = token
} else {
acc.inactiveTokens[tokenAddress] = token
}
if (isListEnabled) {
acc.activeTokens[tokenAddress] = token
} else {
acc.inactiveTokens[tokenAddress] = token
}
})
}
})

return acc
},
{ activeTokens: {}, inactiveTokens: {}, lists: {} }
)
return acc
}, defaultUpdateState)

localStorage.setItem(LAST_UPDATE_TIME_KEY(chainId), Date.now().toString())