fix updating git status

pull/4896/head
yann300 5 months ago committed by Aniket
parent e381c09e33
commit e841860c17
  1. 65
      libs/remix-ui/statusbar/src/lib/components/gitStatus.tsx

@ -13,46 +13,31 @@ export interface GitStatusProps {
export default function GitStatus({ plugin, gitBranchName, setGitBranchName }: GitStatusProps) { export default function GitStatus({ plugin, gitBranchName, setGitBranchName }: GitStatusProps) {
useEffect(() => { useEffect(() => {
const run = async () => { plugin.on('filePanel', 'setWorkspace', async (workspace) => {
plugin.on('filePanel', 'setWorkspace', async (workspace) => { const isGit = await plugin.call('fileManager', 'isGitRepo')
const isGit = await plugin.call('fileManager', 'isGitRepo') if (isGit) {
if (isGit) { setGitBranchName(workspace.name)
setGitBranchName(workspace.name) } else {
} else { setGitBranchName('Not a git repo')
setGitBranchName('Not a git repo') }
} })
}) plugin.on('filePanel', 'workspaceInitializationCompleted', async () => {
} const isGit = await plugin.call('fileManager', 'isGitRepo')
run() if (isGit) {
}, [gitBranchName, plugin.isGitRepo]) const workspace = localStorage.getItem('currentWorkspace')
setGitBranchName(workspace)
useEffect(() => { } else {
const run = async () => { setGitBranchName('Not a git repo')
plugin.on('filePanel', 'workspaceInitializationCompleted', async () => { }
const isGit = await plugin.call('fileManager', 'isGitRepo') })
if (isGit) { plugin.on('dGitProvider', 'init', async () => {
const workspace = localStorage.getItem('currentWorkspace') const isGit = await plugin.call('fileManager', 'isGitRepo')
setGitBranchName(workspace) if (isGit) {
} else { const workspace = localStorage.getItem('currentWorkspace')
setGitBranchName('Not a git repo') setGitBranchName(workspace)
} }
}) })
} }, [])
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])
const lightDgitUp = async () => { const lightDgitUp = async () => {
const isActive = await plugin.call('manager', 'isActive', 'dgit') const isActive = await plugin.call('manager', 'isActive', 'dgit')

Loading…
Cancel
Save