From 04a2d8dfb850235766ddbc11121a8664bf77dc56 Mon Sep 17 00:00:00 2001 From: aidencao Date: Wed, 30 Aug 2023 10:56:17 +0800 Subject: [PATCH] feat(dcellar-web-ui): remove drawer close btn & add debounce refresh --- apps/dcellar-web-ui/src/base/theme/index.ts | 5 + .../src/components/common/DCDrawer/index.tsx | 14 ++- .../accounts/components/AccountDetail.tsx | 15 +-- .../bucket/components/DetailDrawer.tsx | 12 +-- .../modules/bucket/components/NewBucket.tsx | 12 ++- .../buckets/List/components/CreateBucket.tsx | 2 - .../group/components/AddGroupMember.tsx | 7 +- .../modules/group/components/CreateGroup.tsx | 2 - .../modules/group/components/EditGroup.tsx | 2 - .../src/modules/group/components/NewGroup.tsx | 12 ++- .../group/components/RemoveGroupMember.tsx | 3 +- .../object/components/CreateFolder.tsx | 27 ++++-- .../object/components/DetailObject.tsx | 94 +++++++++---------- .../modules/object/components/NewObject.tsx | 40 ++++---- .../modules/object/components/ShareDrawer.tsx | 4 +- .../src/modules/upload/UploadObjects.tsx | 2 - .../src/modules/upload/UploadingObjects.tsx | 11 ++- .../src/store/slices/accounts.ts | 3 +- .../dcellar-web-ui/src/store/slices/bucket.ts | 5 +- apps/dcellar-web-ui/src/store/slices/group.ts | 5 +- 20 files changed, 141 insertions(+), 136 deletions(-) diff --git a/apps/dcellar-web-ui/src/base/theme/index.ts b/apps/dcellar-web-ui/src/base/theme/index.ts index 8378a92a..e4620cd1 100644 --- a/apps/dcellar-web-ui/src/base/theme/index.ts +++ b/apps/dcellar-web-ui/src/base/theme/index.ts @@ -22,6 +22,11 @@ export const theme = { top: 65, maxW: '500px', }, + '.ui-drawer .ui-drawer-body': { + width: 'calc(100% + 48px)', + marginLeft: -24, + padding: '0 24px', + }, }, }, }, diff --git a/apps/dcellar-web-ui/src/components/common/DCDrawer/index.tsx b/apps/dcellar-web-ui/src/components/common/DCDrawer/index.tsx index 398ab201..aeb75a40 100644 --- a/apps/dcellar-web-ui/src/components/common/DCDrawer/index.tsx +++ b/apps/dcellar-web-ui/src/components/common/DCDrawer/index.tsx @@ -1,14 +1,23 @@ import React from 'react'; -import { QDrawer, QDrawerProps } from '@totejs/uikit'; +import { QDrawer, QDrawerCloseButton, QDrawerProps } from '@totejs/uikit'; import { reportEvent } from '@/utils/reportEvent'; import { GAShow } from '../GATracker'; export interface DCDrawerProps extends QDrawerProps { gaShowName?: string; gaShowData?: Record; gaClickCloseName?: string; + showCloseBtn?: boolean; } export const DCDrawer = (props: DCDrawerProps) => { - const { children, gaShowName, gaShowData, gaClickCloseName, onClose, ...restProps } = props; + const { + children, + gaShowName, + gaShowData, + gaClickCloseName, + onClose, + showCloseBtn = true, + ...restProps + } = props; const onBeforeClose = () => { if (gaClickCloseName) { @@ -30,6 +39,7 @@ export const DCDrawer = (props: DCDrawerProps) => { rootProps={{ top: 64.5 }} {...restProps} > + {showCloseBtn && } {children} diff --git a/apps/dcellar-web-ui/src/modules/accounts/components/AccountDetail.tsx b/apps/dcellar-web-ui/src/modules/accounts/components/AccountDetail.tsx index 347c58cb..10c3d9ab 100644 --- a/apps/dcellar-web-ui/src/modules/accounts/components/AccountDetail.tsx +++ b/apps/dcellar-web-ui/src/modules/accounts/components/AccountDetail.tsx @@ -1,15 +1,5 @@ import { useAppSelector } from '@/store'; -import { - Box, - Divider, - Flex, - Image, - Link, - QDrawerBody, - QDrawerCloseButton, - QDrawerHeader, - Text, -} from '@totejs/uikit'; +import { Box, Divider, Flex, Image, Link, QDrawerBody, QDrawerHeader, Text } from '@totejs/uikit'; import React from 'react'; import { GREENFIELD_CHAIN_EXPLORER_URL, assetPrefix } from '@/base/env'; import { trimAddress } from '@/utils/string'; @@ -26,7 +16,7 @@ import { getNumInDigits } from '@/utils/wallet'; export const AccountDetail = ({ loading, title, accountDetail, lockFee }: any) => { const bnbPrice = useAppSelector(selectBnbPrice); const isOwnerAccount = accountDetail?.name?.toLowerCase() === 'owner account'; - const {bankBalance} = useAppSelector(root=> root.accounts); + const { bankBalance } = useAppSelector((root) => root.accounts); const balance = isOwnerAccount ? BigNumber(accountDetail?.staticBalance || 0) .plus(BigNumber(bankBalance)) @@ -120,7 +110,6 @@ export const AccountDetail = ({ loading, title, accountDetail, lockFee }: any) = {title} - (function DetailDrawer() { return ( - Bucket Detail diff --git a/apps/dcellar-web-ui/src/modules/bucket/components/NewBucket.tsx b/apps/dcellar-web-ui/src/modules/bucket/components/NewBucket.tsx index 9704d5d7..ba001816 100644 --- a/apps/dcellar-web-ui/src/modules/bucket/components/NewBucket.tsx +++ b/apps/dcellar-web-ui/src/modules/bucket/components/NewBucket.tsx @@ -1,10 +1,11 @@ -import { memo } from 'react'; +import { memo, useCallback } from 'react'; import { CreateBucketButton } from '@/modules/bucket/bucket.style'; import { AddIcon } from '@totejs/icons'; import { useAppDispatch, useAppSelector } from '@/store'; import { setEditCreate, setupBuckets } from '@/store/slices/bucket'; import { Flex } from '@totejs/uikit'; import RefreshIcon from '@/public/images/icons/refresh.svg'; +import { debounce } from 'lodash-es'; interface NewBucketProps { showRefresh?: boolean; @@ -14,9 +15,12 @@ export const NewBucket = memo(function NewBucket({ showRefresh = const dispatch = useAppDispatch(); const { loginAccount } = useAppSelector((root) => root.persist); - const onRefresh = () => { - dispatch(setupBuckets(loginAccount, true)); - }; + const onRefresh = useCallback( + debounce(() => { + dispatch(setupBuckets(loginAccount, true)); + }, 300), + [loginAccount], + ); return ( diff --git a/apps/dcellar-web-ui/src/modules/buckets/List/components/CreateBucket.tsx b/apps/dcellar-web-ui/src/modules/buckets/List/components/CreateBucket.tsx index 0009c618..5179578a 100644 --- a/apps/dcellar-web-ui/src/modules/buckets/List/components/CreateBucket.tsx +++ b/apps/dcellar-web-ui/src/modules/buckets/List/components/CreateBucket.tsx @@ -8,7 +8,6 @@ import { InputRightElement, Link, QDrawerBody, - QDrawerCloseButton, QDrawerFooter, QDrawerHeader, Text, @@ -423,7 +422,6 @@ export const CreateBucket = ({ isOpen, onClose, refetch }: Props) => { setStatus('pending')} /> )} - Create a Bucket diff --git a/apps/dcellar-web-ui/src/modules/group/components/AddGroupMember.tsx b/apps/dcellar-web-ui/src/modules/group/components/AddGroupMember.tsx index db235af9..fe7361cd 100644 --- a/apps/dcellar-web-ui/src/modules/group/components/AddGroupMember.tsx +++ b/apps/dcellar-web-ui/src/modules/group/components/AddGroupMember.tsx @@ -16,7 +16,7 @@ import { } from '@/modules/file/constant'; import { useUnmount, useUpdateEffect } from 'ahooks'; import { DCDrawer } from '@/components/common/DCDrawer'; -import { Flex, QDrawerBody, QDrawerCloseButton, QDrawerHeader, Text, toast } from '@totejs/uikit'; +import { Flex, QDrawerBody, QDrawerHeader, Text, toast } from '@totejs/uikit'; import { DCComboBox } from '@/components/common/DCComboBox'; import { DCButton } from '@/components/common/DCButton'; import ComingSoon from '@/components/common/SvgIcon/members.svg'; @@ -86,10 +86,10 @@ export const AddGroupMember = memo(function AddMember() { const curTimeStamp = await getUtcZeroTimestamp(); const expirationTimestamp = Math.floor(curTimeStamp + 10 * 60 * 60 * 1000); const expirationDate = new Date(expirationTimestamp); - const membersToAdd = values.map(item => ({ + const membersToAdd = values.map((item) => ({ member: item, expirationTime: toTimestamp(expirationDate), - })) + })); const payload = { operator: loginAccount, @@ -118,7 +118,6 @@ export const AddGroupMember = memo(function AddMember() { return ( - Add Members diff --git a/apps/dcellar-web-ui/src/modules/group/components/CreateGroup.tsx b/apps/dcellar-web-ui/src/modules/group/components/CreateGroup.tsx index 39764802..affc65ed 100644 --- a/apps/dcellar-web-ui/src/modules/group/components/CreateGroup.tsx +++ b/apps/dcellar-web-ui/src/modules/group/components/CreateGroup.tsx @@ -5,7 +5,6 @@ import { FormControl, FormLabel, QDrawerBody, - QDrawerCloseButton, QDrawerFooter, QDrawerHeader, Text, @@ -136,7 +135,6 @@ export const CreateGroup = memo(function CreateGroup() { return ( - Create a Group diff --git a/apps/dcellar-web-ui/src/modules/group/components/EditGroup.tsx b/apps/dcellar-web-ui/src/modules/group/components/EditGroup.tsx index 76389443..2bf79935 100644 --- a/apps/dcellar-web-ui/src/modules/group/components/EditGroup.tsx +++ b/apps/dcellar-web-ui/src/modules/group/components/EditGroup.tsx @@ -5,7 +5,6 @@ import { FormControl, FormLabel, QDrawerBody, - QDrawerCloseButton, QDrawerFooter, QDrawerHeader, Text, @@ -135,7 +134,6 @@ export const EditGroup = memo(function CreateGroup() { return ( - Edit Description diff --git a/apps/dcellar-web-ui/src/modules/group/components/NewGroup.tsx b/apps/dcellar-web-ui/src/modules/group/components/NewGroup.tsx index 945b6baf..58608f55 100644 --- a/apps/dcellar-web-ui/src/modules/group/components/NewGroup.tsx +++ b/apps/dcellar-web-ui/src/modules/group/components/NewGroup.tsx @@ -1,9 +1,10 @@ -import { memo } from 'react'; +import { memo, useCallback } from 'react'; import { Flex } from '@totejs/uikit'; import { useAppDispatch, useAppSelector } from '@/store'; import { setCreatingGroup, setupGroups } from '@/store/slices/group'; import RefreshIcon from '@/public/images/icons/refresh.svg'; import { DCButton } from '@/components/common/DCButton'; +import { debounce } from 'lodash-es'; interface NewGroupProps { showRefresh?: boolean; @@ -13,9 +14,12 @@ export const NewGroup = memo(function NewGroup({ showRefresh = tr const dispatch = useAppDispatch(); const { loginAccount } = useAppSelector((root) => root.persist); - const onRefresh = () => { - dispatch(setupGroups(loginAccount, true)); - }; + const onRefresh = useCallback( + debounce(() => { + dispatch(setupGroups(loginAccount, true)); + }, 300), + [loginAccount], + ); const onCreate = () => { dispatch(setCreatingGroup(true)); diff --git a/apps/dcellar-web-ui/src/modules/group/components/RemoveGroupMember.tsx b/apps/dcellar-web-ui/src/modules/group/components/RemoveGroupMember.tsx index a5c08691..1fa08ddc 100644 --- a/apps/dcellar-web-ui/src/modules/group/components/RemoveGroupMember.tsx +++ b/apps/dcellar-web-ui/src/modules/group/components/RemoveGroupMember.tsx @@ -16,7 +16,7 @@ import { } from '@/modules/file/constant'; import { useUnmount, useUpdateEffect } from 'ahooks'; import { DCDrawer } from '@/components/common/DCDrawer'; -import { Flex, QDrawerBody, QDrawerCloseButton, QDrawerHeader, Text, toast } from '@totejs/uikit'; +import { Flex, QDrawerBody, QDrawerHeader, Text, toast } from '@totejs/uikit'; import { DCComboBox } from '@/components/common/DCComboBox'; import { DCButton } from '@/components/common/DCButton'; import ComingSoon from '@/components/common/SvgIcon/members.svg'; @@ -107,7 +107,6 @@ export const RemoveGroupMember = memo(function RemoveGro return ( - Remove Members diff --git a/apps/dcellar-web-ui/src/modules/object/components/CreateFolder.tsx b/apps/dcellar-web-ui/src/modules/object/components/CreateFolder.tsx index 72140d1e..b80742d1 100644 --- a/apps/dcellar-web-ui/src/modules/object/components/CreateFolder.tsx +++ b/apps/dcellar-web-ui/src/modules/object/components/CreateFolder.tsx @@ -5,12 +5,10 @@ import { FormControl, Link, QDrawerBody, - QDrawerCloseButton, QDrawerFooter, QDrawerHeader, Text, toast, - useDisclosure, } from '@totejs/uikit'; import { InputItem } from '@/components/formitems/InputItem'; import { Fees } from '@/modules/file/components/Fees'; @@ -282,7 +280,9 @@ export const CreateFolder = memo(function CreateFolderDrawer({ refet ) => { const fullPath = getPath(folderName, folders); const file = new File([], fullPath, { type: 'text/plain' }); - const { seedString } = await dispatch(getSpOffChainData(loginAccount, primarySp.operatorAddress)); + const { seedString } = await dispatch( + getSpOffChainData(loginAccount, primarySp.operatorAddress), + ); const hashResult = await checksumWorkerApi?.generateCheckSumV2(file); const createObjectPayload: TBaseGetCreateObject = { bucketName, @@ -326,22 +326,30 @@ export const CreateFolder = memo(function CreateFolderDrawer({ refet useEffect(() => { if (isEmpty(preLockFeeObject)) { - return + return; } const nGasFee = BigNumber(gasFee); - console.log('isOwnerAccount', isOwnerAccount, preLockFee, payLockFeeAccount.staticBalance, bankBalance) + console.log( + 'isOwnerAccount', + isOwnerAccount, + preLockFee, + payLockFeeAccount.staticBalance, + bankBalance, + ); if (isOwnerAccount) { if (BigNumber(preLockFee).gt(BigNumber(payLockFeeAccount.staticBalance).plus(bankBalance))) { setTimeout(() => setFormErrors([GET_GAS_FEE_LACK_BALANCE_ERROR]), 100); } } else { - if (BigNumber(preLockFee).gt(BigNumber(payLockFeeAccount.staticBalance)) || nGasFee.gt(BigNumber(bankBalance))) { - console.log('2131232131221') + if ( + BigNumber(preLockFee).gt(BigNumber(payLockFeeAccount.staticBalance)) || + nGasFee.gt(BigNumber(bankBalance)) + ) { + console.log('2131232131221'); setTimeout(() => setFormErrors([LOCK_FEE_LACK_BALANCE_ERROR]), 100); } } - - }, [gasFee, bankBalance, preLockFee, payLockFeeAccount.staticBalance, preLockFeeObject, loginAccount, isOwnerAccount]); + }, [gasFee, bankBalance, preLockFee, payLockFeeAccount.staticBalance, preLockFeeObject, loginAccount, isOwnerAccount]); useEffect(() => { setFormErrors([]); @@ -357,7 +365,6 @@ export const CreateFolder = memo(function CreateFolderDrawer({ refet gaShowName="dc.file.create_folder_m.0.show" gaClickCloseName="dc.file.create_folder_m.close.click" > - Create a Folder { Object Detail - @@ -328,53 +326,53 @@ export const DetailObject = (props: modalProps) => { - - - {renderPropRow('Date Created', formatFullTime(+objectInfo.ObjectInfo.CreateAt * 1000))} - {renderAddressLink( - 'Object ID', - formatId(Number(objectInfo.ObjectInfo?.Id)), - 'dc.file.f_detail_pop.id.click', - 'dc.file.f_detail_pop.copy_id.click', - 'object', - )} - {renderAddressLink( - 'Primary SP address', - primarySp.operatorAddress, - 'dc.file.f_detail_pop.spadd.click', - 'dc.file.f_detail_pop.copy_spadd.click', - )} - {renderAddressLink( - 'Primary SP seal address', - primarySp.operatorAddress, - 'dc.file.f_detail_pop.seal.click', - 'dc.file.f_detail_pop.copy_seal.click', - )} - {renderAddressLink( - 'Create transaction hash', - objectInfo.CreateTxHash, - 'dc.object.f_detail_pop.CreateTxHash.click', - 'dc.object.f_detail_pop.copy_create_tx_hash.click', - 'tx', - )} - {renderAddressLink( - 'Seal transaction hash', - objectInfo.SealTxHash, - 'dc.object.f_detail_pop.SealTxHash.click', - 'dc.object.f_detail_pop.copy_seal_tx_hash.click', - 'tx', - )} - {editDetail.visibility === VisibilityType.VISIBILITY_TYPE_PUBLIC_READ && - renderPropRow( - 'Universal link', - renderUrlWithLink( - `${primarySp.endpoint}/view/${bucketName}/${encodeObjectName(editDetail.name)}`, - true, - 32, - 'dc.file.f_detail_pop.universal.click', - 'dc.file.f_detail_pop.copy_universal.click', - ), + + + {renderPropRow('Date Created', formatFullTime(+objectInfo.ObjectInfo.CreateAt * 1000))} + {renderAddressLink( + 'Object ID', + formatId(Number(objectInfo.ObjectInfo?.Id)), + 'dc.file.f_detail_pop.id.click', + 'dc.file.f_detail_pop.copy_id.click', + 'object', + )} + {renderAddressLink( + 'Primary SP address', + primarySp.operatorAddress, + 'dc.file.f_detail_pop.spadd.click', + 'dc.file.f_detail_pop.copy_spadd.click', + )} + {renderAddressLink( + 'Primary SP seal address', + primarySp.operatorAddress, + 'dc.file.f_detail_pop.seal.click', + 'dc.file.f_detail_pop.copy_seal.click', + )} + {renderAddressLink( + 'Create transaction hash', + objectInfo.CreateTxHash, + 'dc.object.f_detail_pop.CreateTxHash.click', + 'dc.object.f_detail_pop.copy_create_tx_hash.click', + 'tx', + )} + {renderAddressLink( + 'Seal transaction hash', + objectInfo.SealTxHash, + 'dc.object.f_detail_pop.SealTxHash.click', + 'dc.object.f_detail_pop.copy_seal_tx_hash.click', + 'tx', )} + {editDetail.visibility === VisibilityType.VISIBILITY_TYPE_PUBLIC_READ && + renderPropRow( + 'Universal link', + renderUrlWithLink( + `${primarySp.endpoint}/view/${bucketName}/${encodeObjectName(editDetail.name)}`, + true, + 32, + 'dc.file.f_detail_pop.universal.click', + 'dc.file.f_detail_pop.copy_universal.click', + ), + )} diff --git a/apps/dcellar-web-ui/src/modules/object/components/NewObject.tsx b/apps/dcellar-web-ui/src/modules/object/components/NewObject.tsx index 51417bdb..a49ec800 100644 --- a/apps/dcellar-web-ui/src/modules/object/components/NewObject.tsx +++ b/apps/dcellar-web-ui/src/modules/object/components/NewObject.tsx @@ -1,4 +1,4 @@ -import React, { ChangeEvent, memo } from 'react'; +import React, { ChangeEvent, memo, useCallback } from 'react'; import { useAppDispatch, useAppSelector } from '@/store'; import { GAClick } from '@/components/common/GATracker'; import { @@ -31,6 +31,7 @@ import { getSpOffChainData } from '@/store/slices/persist'; import { BatchOperations } from '@/modules/object/components/BatchOperations'; import { setupBucketQuota } from '@/store/slices/bucket'; import { MenuCloseIcon } from '@totejs/icons'; +import { debounce } from 'lodash-es'; interface NewObjectProps { showRefresh?: boolean; gaFolderClickName?: string; @@ -167,23 +168,26 @@ export const NewObject = memo(function NewObject({ e.target.value = ''; }; - const refreshList = async () => { - const { seedString } = await dispatch( - getSpOffChainData(loginAccount, primarySp.operatorAddress), - ); - const query = new URLSearchParams(); - const params = { - seedString, - query, - endpoint: primarySp.endpoint, - }; - dispatch(setSelectedRowKeys([])); - dispatch(setupBucketQuota(bucketName)); - dispatch(setListRefreshing(true)); - dispatch(setRestoreCurrent(false)); - await dispatch(setupListObjects(params)); - dispatch(setListRefreshing(false)); - }; + const refreshList = useCallback( + debounce(async () => { + const { seedString } = await dispatch( + getSpOffChainData(loginAccount, primarySp.operatorAddress), + ); + const query = new URLSearchParams(); + const params = { + seedString, + query, + endpoint: primarySp.endpoint, + }; + dispatch(setSelectedRowKeys([])); + dispatch(setupBucketQuota(bucketName)); + dispatch(setListRefreshing(true)); + dispatch(setRestoreCurrent(false)); + await dispatch(setupListObjects(params)); + dispatch(setListRefreshing(false)); + }, 300), + [loginAccount, primarySp?.operatorAddress, bucketName], + ); return ( diff --git a/apps/dcellar-web-ui/src/modules/object/components/ShareDrawer.tsx b/apps/dcellar-web-ui/src/modules/object/components/ShareDrawer.tsx index ad97fd4a..e6f795cf 100644 --- a/apps/dcellar-web-ui/src/modules/object/components/ShareDrawer.tsx +++ b/apps/dcellar-web-ui/src/modules/object/components/ShareDrawer.tsx @@ -4,7 +4,6 @@ import { Flex, Image, QDrawerBody, - QDrawerCloseButton, QDrawerFooter, QDrawerHeader, Text, @@ -109,8 +108,7 @@ export const ShareDrawer = memo(function ShareDrawer() { return ( <> - - {from !== 'drawer' && } + {from === 'drawer' && } (function UploadObjects() { return ( - Upload Objects {!isEmpty(selectedFiles) && ( diff --git a/apps/dcellar-web-ui/src/modules/upload/UploadingObjects.tsx b/apps/dcellar-web-ui/src/modules/upload/UploadingObjects.tsx index 1a3c0eda..e176be36 100644 --- a/apps/dcellar-web-ui/src/modules/upload/UploadingObjects.tsx +++ b/apps/dcellar-web-ui/src/modules/upload/UploadingObjects.tsx @@ -5,7 +5,6 @@ import { Flex, Image, QDrawerBody, - QDrawerCloseButton, QDrawerHeader, QListItem, Tab, @@ -73,7 +72,6 @@ export const UploadingObjects = () => { if (!queue.length) { return ( <> - Task Management { return ( <> - Task Management setActiveKey(key)}> @@ -162,7 +159,13 @@ export const UploadingObjects = () => { status={task.status} w={300} /> - !!item).join('/') + '/'} /> + !!item) + .join('/') + '/' + } + /> diff --git a/apps/dcellar-web-ui/src/store/slices/accounts.ts b/apps/dcellar-web-ui/src/store/slices/accounts.ts index b10b0855..09b87286 100644 --- a/apps/dcellar-web-ui/src/store/slices/accounts.ts +++ b/apps/dcellar-web-ui/src/store/slices/accounts.ts @@ -191,7 +191,8 @@ export const setupPAList = (forceLoading = false) => async (dispatch: any, getState: GetState) => { const { loginAccount } = getState().persist; - const { PAList } = getState().accounts; + const { PAList, isLoadingPAList } = getState().accounts; + if (isLoadingPAList) return; if (!PAList.length || forceLoading) { dispatch(setLoadingPAList(true)); } diff --git a/apps/dcellar-web-ui/src/store/slices/bucket.ts b/apps/dcellar-web-ui/src/store/slices/bucket.ts index 41c3873b..e571e752 100644 --- a/apps/dcellar-web-ui/src/store/slices/bucket.ts +++ b/apps/dcellar-web-ui/src/store/slices/bucket.ts @@ -40,7 +40,7 @@ const initialState: BucketState = { buckets: {}, bucketInfo: {}, quotas: {}, - loading: true, + loading: false, currentPage: 0, discontinue: false, owner: true, @@ -138,8 +138,9 @@ export const setupBuckets = (address: string, forceLoading = false) => async (dispatch: AppDispatch, getState: GetState) => { const { oneSp, spInfo } = getState().sp; - const { buckets } = getState().bucket; + const { buckets, loading } = getState().bucket; const sp = spInfo[oneSp]; + if (loading) return; if (!(address in buckets) || forceLoading) { dispatch(setLoading(true)); } diff --git a/apps/dcellar-web-ui/src/store/slices/group.ts b/apps/dcellar-web-ui/src/store/slices/group.ts index 154edbba..a8322cd2 100644 --- a/apps/dcellar-web-ui/src/store/slices/group.ts +++ b/apps/dcellar-web-ui/src/store/slices/group.ts @@ -17,7 +17,7 @@ interface GroupState { const initialState: GroupState = { groups: {}, - loading: true, + loading: false, currentPage: 0, creatingGroup: false, editGroup: {} as GroupInfo, @@ -77,7 +77,8 @@ export const selectGroupList = (address: string) => (root: AppState) => { export const setupGroups = (loginAccount: string, forceLoading = false) => async (dispatch: AppDispatch, getState: GetState) => { - const { groups } = getState().group; + const { groups, loading } = getState().group; + if (loading) return; if (!(loginAccount in groups) || forceLoading) { dispatch(setLoading(true)); }