import { Messenger } from '@estruyf/vscode/dist/client'; import { EventData } from '@estruyf/vscode/dist/models'; import { ArrowPathIcon } from '@heroicons/react/24/outline'; import * as React from 'react'; import { useEffect, useState } from 'react'; import { useRecoilValue } from 'recoil'; import { GeneralCommands } from '../../../constants'; import useThemeColors from '../../hooks/useThemeColors'; import { SettingsSelector } from '../../state'; import * as l10n from '@vscode/l10n'; import { LocalizationKey } from '../../../localization'; export interface ISyncButtonProps { } export const SyncButton: React.FunctionComponent = ( _: React.PropsWithChildren ) => { const settings = useRecoilValue(SettingsSelector); const [isSyncing, setIsSyncing] = useState(false); const { getColors } = useThemeColors(); const pull = () => { Messenger.send(GeneralCommands.toVSCode.git.sync); }; const messageListener = (message: MessageEvent>) => { const { command } = message.data; if (command === GeneralCommands.toWebview.git.syncingStart) { setIsSyncing(true); } else if (command === GeneralCommands.toWebview.git.syncingEnd) { setIsSyncing(false); } }; useEffect(() => { Messenger.listen(messageListener); return () => { Messenger.unlisten(messageListener); }; }, []); if (!settings?.git?.actions || !settings?.git.isGitRepo) { return null; } return (
); };