From e841860c17eb693737c14ee839dee8a3717b9d8c Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 17 Jun 2024 22:24:52 +0200 Subject: [PATCH] fix updating git status --- .../src/lib/components/gitStatus.tsx | 65 +++++++------------ 1 file changed, 25 insertions(+), 40 deletions(-) diff --git a/libs/remix-ui/statusbar/src/lib/components/gitStatus.tsx b/libs/remix-ui/statusbar/src/lib/components/gitStatus.tsx index 4f579e2982..fa93315167 100644 --- a/libs/remix-ui/statusbar/src/lib/components/gitStatus.tsx +++ b/libs/remix-ui/statusbar/src/lib/components/gitStatus.tsx @@ -13,46 +13,31 @@ export interface GitStatusProps { export default function GitStatus({ plugin, gitBranchName, setGitBranchName }: GitStatusProps) { useEffect(() => { - const run = async () => { - plugin.on('filePanel', 'setWorkspace', async (workspace) => { - const isGit = await plugin.call('fileManager', 'isGitRepo') - if (isGit) { - setGitBranchName(workspace.name) - } else { - setGitBranchName('Not a git repo') - } - }) - } - run() - }, [gitBranchName, plugin.isGitRepo]) - - useEffect(() => { - const run = async () => { - plugin.on('filePanel', 'workspaceInitializationCompleted', async () => { - const isGit = await plugin.call('fileManager', 'isGitRepo') - if (isGit) { - const workspace = localStorage.getItem('currentWorkspace') - setGitBranchName(workspace) - } else { - setGitBranchName('Not a git repo') - } - }) - } - run() - }, [gitBranchName, plugin.isGitRepo]) - - useEffect(() => { - const run = async () => { - plugin.on('dGitProvider', 'init', async () => { - const isGit = await plugin.call('fileManager', 'isGitRepo') - if (isGit) { - const workspace = localStorage.getItem('currentWorkspace') - setGitBranchName(workspace) - } - }) - } - run() - }, [gitBranchName, plugin.isGitRepo]) + plugin.on('filePanel', 'setWorkspace', async (workspace) => { + const isGit = await plugin.call('fileManager', 'isGitRepo') + if (isGit) { + setGitBranchName(workspace.name) + } else { + setGitBranchName('Not a git repo') + } + }) + plugin.on('filePanel', 'workspaceInitializationCompleted', async () => { + const isGit = await plugin.call('fileManager', 'isGitRepo') + if (isGit) { + const workspace = localStorage.getItem('currentWorkspace') + setGitBranchName(workspace) + } else { + setGitBranchName('Not a git repo') + } + }) + plugin.on('dGitProvider', 'init', async () => { + const isGit = await plugin.call('fileManager', 'isGitRepo') + if (isGit) { + const workspace = localStorage.getItem('currentWorkspace') + setGitBranchName(workspace) + } + }) + }, []) const lightDgitUp = async () => { const isActive = await plugin.call('manager', 'isActive', 'dgit')