Skip to content

Commit

Permalink
handle sync in contract screen
Browse files Browse the repository at this point in the history
  • Loading branch information
jakzaizzat committed Apr 30, 2024
1 parent b8d1465 commit fc6fd95
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,39 @@ import { AnimatedRefreshIcon } from '~/components/AnimatedRefreshIcon';
import { GalleryTouchableOpacity } from '~/components/GalleryTouchableOpacity';
import { IconContainer } from '~/components/IconContainer';
import { BaseM } from '~/components/Text';
import { useSyncTokensActions } from '~/contexts/SyncTokensContext';

type Props = {
contractId: string;
contractName: string;
isMultiselectMode: boolean;
setIsMultiselectMode: (value: boolean) => void;
onSelectedAllPress: () => void;
hasSelectedItems: boolean;
ownershipTypeFilter: 'Collected' | 'Created';
};

export function NftSelectorContractToolbar({
contractId,
contractName,
isMultiselectMode,
setIsMultiselectMode,
onSelectedAllPress,
hasSelectedItems,
ownershipTypeFilter,
}: Props) {
const { isSyncing, isSyncingCreatedTokens, syncCreatedTokensForExistingContract } =
useSyncTokensActions();

const handleMultiselectPress = useCallback(() => {
setIsMultiselectMode?.(!isMultiselectMode);
}, [isMultiselectMode, setIsMultiselectMode]);

const handleSyncTokensForContract = useCallback(async () => {
if (!contractId) return;
syncCreatedTokensForExistingContract(contractId);
}, [syncCreatedTokensForExistingContract, contractId]);

return (
<View className="flex-row justify-between px-4 pt-4">
<BaseM weight="Bold">{contractName}</BaseM>
Expand All @@ -52,10 +65,8 @@ export function NftSelectorContractToolbar({
color={isMultiselectMode ? 'active' : 'default'}
/>
<AnimatedRefreshIcon
// onSync={handleSync}
// isSyncing={ownershipTypeFilter === 'Collected' ? isSyncing : isSyncingCreatedTokens}
onSync={() => {}}
isSyncing={false}
onSync={handleSyncTokensForContract}
isSyncing={ownershipTypeFilter === 'Collected' ? isSyncing : isSyncingCreatedTokens}
eventElementId="NftSelectorSelectorRefreshButton"
eventName="NftSelectorSelectorRefreshButton pressed"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,13 @@ export function GalleryEditorNftSelectorContractScreen() {
}
/>
<NftSelectorContractToolbar
contractId={contractId}
contractName={contractName}
isMultiselectMode={isMultiselectMode}
setIsMultiselectMode={setIsMultiselectMode}
onSelectedAllPress={handleSelectedAllPress}
hasSelectedItems={selectedTokens.length > 0}
ownershipTypeFilter={route.params.ownerFilter || 'Collected'}
/>
<NftSelectorContractPickerGrid
isCreator={isCreator}
Expand Down

0 comments on commit fc6fd95

Please sign in to comment.