-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1037 from alephium/optimize-tanstack
Optimize Tanstack
- Loading branch information
Showing
62 changed files
with
707 additions
and
370 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"alephium-desktop-wallet": patch | ||
--- | ||
|
||
Improve performance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "alephium-desktop-wallet", | ||
"description": "The official Alephium wallet", | ||
"version": "2.4.4", | ||
"version": "2.5.0-rc.0", | ||
"author": "Alephium dev <[email protected]>", | ||
"main": "dist-electron/main.js", | ||
"homepage": "./", | ||
|
@@ -123,7 +123,7 @@ | |
"jsdom": "^21.1.1", | ||
"lodash": "^4.17.21", | ||
"lucide-react": "^0.287.0", | ||
"nanoid": "^4.0.0", | ||
"nanoid": "^3.3.8", | ||
"posthog-js": "^1.52.0", | ||
"qrloop": "^1.4.1", | ||
"react": "^18.2.0", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
apps/desktop-wallet/src/api/apiDataHooks/utils/useFetchWalletBalancesAlph.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
Copyright 2018 - 2024 The Alephium Authors | ||
This file is part of the alephium project. | ||
The library is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Lesser General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
The library is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public License | ||
along with the library. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import { useQueries, UseQueryResult } from '@tanstack/react-query' | ||
|
||
import { addressAlphBalancesQuery, AddressAlphBalancesQueryFnData } from '@/api/queries/addressQueries' | ||
import { useAppSelector } from '@/hooks/redux' | ||
import { useUnsortedAddressesHashes } from '@/hooks/useUnsortedAddresses' | ||
import { selectCurrentlyOnlineNetworkId } from '@/storage/network/networkSelectors' | ||
|
||
const useFetchWalletBalancesAlph = <T>( | ||
combine: (results: UseQueryResult<AddressAlphBalancesQueryFnData>[]) => { | ||
data: T | ||
isLoading: boolean | ||
isFetching?: boolean | ||
error?: boolean | ||
} | ||
) => { | ||
const networkId = useAppSelector(selectCurrentlyOnlineNetworkId) | ||
const allAddressHashes = useUnsortedAddressesHashes() | ||
|
||
const { data, isLoading, isFetching, error } = useQueries({ | ||
queries: allAddressHashes.map((addressHash) => addressAlphBalancesQuery({ addressHash, networkId })), | ||
combine | ||
}) | ||
|
||
return { | ||
data, | ||
isLoading, | ||
isFetching, | ||
error | ||
} | ||
} | ||
|
||
export default useFetchWalletBalancesAlph |
48 changes: 48 additions & 0 deletions
48
apps/desktop-wallet/src/api/apiDataHooks/utils/useFetchWalletBalancesTokens.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
Copyright 2018 - 2024 The Alephium Authors | ||
This file is part of the alephium project. | ||
The library is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Lesser General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
The library is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public License | ||
along with the library. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import { useQueries, UseQueryResult } from '@tanstack/react-query' | ||
|
||
import { addressTokensBalancesQuery, AddressTokensBalancesQueryFnData } from '@/api/queries/addressQueries' | ||
import { useAppSelector } from '@/hooks/redux' | ||
import { useUnsortedAddressesHashes } from '@/hooks/useUnsortedAddresses' | ||
import { selectCurrentlyOnlineNetworkId } from '@/storage/network/networkSelectors' | ||
|
||
export const useFetchWalletBalancesTokens = <T>( | ||
combine: (results: UseQueryResult<AddressTokensBalancesQueryFnData>[]) => { | ||
data: T | ||
isLoading: boolean | ||
isFetching?: boolean | ||
error?: boolean | ||
} | ||
) => { | ||
const networkId = useAppSelector(selectCurrentlyOnlineNetworkId) | ||
const allAddressHashes = useUnsortedAddressesHashes() | ||
|
||
const { data, isLoading, isFetching, error } = useQueries({ | ||
queries: allAddressHashes.map((addressHash) => addressTokensBalancesQuery({ addressHash, networkId })), | ||
combine | ||
}) | ||
|
||
return { | ||
data, | ||
isLoading, | ||
isFetching, | ||
error | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 0 additions & 102 deletions
102
apps/desktop-wallet/src/api/apiDataHooks/wallet/useFetchWalletBalancesAlph.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.