1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-24 09:18:09 +00:00

Change shape of returned object & temporary fix for async react-select

This commit is contained in:
Vasek Mlejnsky 2018-08-29 11:36:07 +02:00
parent 8b31b63e1e
commit 07b6c9f486

View File

@ -37,20 +37,21 @@ export const load = (input: string, network: string): AsyncAction => async (disp
const tokens = getState().localStorage.tokens[network]; const tokens = getState().localStorage.tokens[network];
const value = input.toLowerCase(); const value = input.toLowerCase();
const result = tokens.filter(t => t.symbol.toLowerCase().indexOf(value) >= 0 const result = tokens.filter(t => t.symbol.toLowerCase().indexOf(value) >= 0
|| t.address.toLowerCase().indexOf(value) >= 0 || t.address.toLowerCase().indexOf(value) >= 0
|| t.name.toLowerCase().indexOf(value) >= 0); || t.name.toLowerCase().indexOf(value) >= 0);
if (result.length > 0) { if (result.length > 0) {
return { options: result }; // TODO: Temporary fix for async select
// async react-select starts getting very laggy
// when options is a large list (>200 items)
return result.slice(0, 100);
} }
const web3instance = getState().web3.find(w3 => w3.network === network); const web3instance = getState().web3.find(w3 => w3.network === network);
if (!web3instance) return; if (!web3instance) return;
const info = await getTokenInfoAsync(web3instance.erc20, input); const info = await getTokenInfoAsync(web3instance.erc20, input);
if (info) { if (info) {
return { return [info];
options: [info],
};
} }
//await resolveAfter(300000); //await resolveAfter(300000);
//await resolveAfter(3000); //await resolveAfter(3000);