|
|
@ -266,12 +266,18 @@ export const SearchProvider = ({ children = [], reducer = SearchReducer, initial |
|
|
|
await value.reloadFile(file) |
|
|
|
await value.reloadFile(file) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const updateFiles = async () => { |
|
|
|
|
|
|
|
setTimeout(async () => { |
|
|
|
|
|
|
|
setFiles(await getDirectory('/', plugin)) |
|
|
|
|
|
|
|
}, 2000) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
plugin.on('filePanel', 'setWorkspace', async (workspace) => { |
|
|
|
plugin.on('filePanel', 'setWorkspace', async (workspace) => { |
|
|
|
value.setSearchResults(null) |
|
|
|
value.setSearchResults(null) |
|
|
|
value.clearUndo() |
|
|
|
value.clearUndo() |
|
|
|
value.setCurrentWorkspace(workspace.name) |
|
|
|
value.setCurrentWorkspace(workspace.name) |
|
|
|
setFiles(await getDirectory('/', plugin)) |
|
|
|
await updateFiles() |
|
|
|
}) |
|
|
|
}) |
|
|
|
plugin.on('fileManager', 'fileSaved', async (file) => { |
|
|
|
plugin.on('fileManager', 'fileSaved', async (file) => { |
|
|
|
await reloadStateForFile(file) |
|
|
|
await reloadStateForFile(file) |
|
|
@ -280,15 +286,15 @@ export const SearchProvider = ({ children = [], reducer = SearchReducer, initial |
|
|
|
plugin.on('fileManager', 'rootFolderChanged', async (file) => { |
|
|
|
plugin.on('fileManager', 'rootFolderChanged', async (file) => { |
|
|
|
const workspace = await plugin.call('filePanel', 'getCurrentWorkspace') |
|
|
|
const workspace = await plugin.call('filePanel', 'getCurrentWorkspace') |
|
|
|
if (workspace) value.setCurrentWorkspace(workspace.name) |
|
|
|
if (workspace) value.setCurrentWorkspace(workspace.name) |
|
|
|
setFiles(await getDirectory('/', plugin)) |
|
|
|
await updateFiles() |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
plugin.on('fs', 'workingDirChanged', async () => { |
|
|
|
plugin.on('fs', 'workingDirChanged', async () => { |
|
|
|
setFiles(await getDirectory('/', plugin)) |
|
|
|
await updateFiles() |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
plugin.on('fileManager', 'fileAdded', async (file) => { |
|
|
|
plugin.on('fileManager', 'fileAdded', async (file) => { |
|
|
|
setFiles(await getDirectory('/', plugin)) |
|
|
|
await updateFiles() |
|
|
|
await reloadStateForFile(file) |
|
|
|
await reloadStateForFile(file) |
|
|
|
}) |
|
|
|
}) |
|
|
|
plugin.on('fileManager', 'currentFileChanged', async (file) => { |
|
|
|
plugin.on('fileManager', 'currentFileChanged', async (file) => { |
|
|
@ -300,16 +306,15 @@ export const SearchProvider = ({ children = [], reducer = SearchReducer, initial |
|
|
|
const workspace = await plugin.call('filePanel', 'getCurrentWorkspace') |
|
|
|
const workspace = await plugin.call('filePanel', 'getCurrentWorkspace') |
|
|
|
if (workspace && workspace.name) { |
|
|
|
if (workspace && workspace.name) { |
|
|
|
value.setCurrentWorkspace(workspace.name) |
|
|
|
value.setCurrentWorkspace(workspace.name) |
|
|
|
setFiles(await getDirectory('/', plugin)) |
|
|
|
await updateFiles() |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
console.log(e) |
|
|
|
console.log(e) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
setTimeout(async () => { |
|
|
|
|
|
|
|
await fetchWorkspace() |
|
|
|
fetchWorkspace() |
|
|
|
}, 5000) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return () => { |
|
|
|
return () => { |
|
|
|
plugin.off('fileManager', 'fileChanged') |
|
|
|
plugin.off('fileManager', 'fileChanged') |
|
|
|
plugin.off('filePanel', 'setWorkspace') |
|
|
|
plugin.off('filePanel', 'setWorkspace') |
|
|
|