fix or open folders

pull/4964/head
bunsenstraat 5 months ago
parent 1c04cc41f5
commit 986ec1ece3
  1. 1
      apps/remixdesktop/src/plugins/foundryPlugin.ts
  2. 28
      apps/remixdesktop/src/plugins/fsPlugin.ts
  3. 0
      apps/remixdesktop/test/tests/app/hardhat.test.ts

@ -158,6 +158,7 @@ class FoundryPluginClient extends ElectronBasePluginRemixdClient {
this.watcher = chokidar.watch(this.cachePath, { depth: 0, ignorePermissionErrors: true, ignoreInitial: true })
this.watcher.on('change', async () => await this.triggerProcessArtifact())
this.watcher.on('add', async () => await this.triggerProcessArtifact())
this.watcher.on('unlink', async () => await this.triggerProcessArtifact())
// process the artifact on activation
this.triggerProcessArtifact()
} catch (e) {

@ -32,6 +32,15 @@ const getBaseName = (pathName: string): string => {
return path.basename(pathName)
}
function onlyUnique(value: recentFolder, index: number, self: recentFolder[]) {
console.log(index, value)
return self.findIndex((rc, index) => rc.path === value.path) === index
}
const deplucateFolderList = (list: recentFolder[]): recentFolder[] => {
return list.filter(onlyUnique)
}
export class FSPlugin extends ElectronBasePlugin {
clients: FSPluginClient[] = []
constructor() {
@ -40,28 +49,28 @@ export class FSPlugin extends ElectronBasePlugin {
}
async onActivation(): Promise<void> {
const config = await this.call('electronconfig' as any, 'readConfig')
const config = await this.call('electronconfig', 'readConfig')
const openedFolders = (config && config.openedFolders) || []
const recentFolders = (config && config.recentFolders) || []
const recentFolders: recentFolder[] = (config && config.recentFolders) || []
this.call('electronconfig', 'writeConfig', {...config,
recentFolders: recentFolders,
recentFolders: deplucateFolderList(recentFolders),
openedFolders: openedFolders})
const foldersToDelete: string[] = []
if (openedFolders && openedFolders.length) {
for (const folder of openedFolders) {
if (recentFolders && recentFolders.length) {
for (const folder of recentFolders) {
try {
const stat = await fs.stat(folder)
const stat = await fs.stat(folder.path);
if (stat.isDirectory()) {
// do nothing
}
} catch (e) {
console.log('error opening folder', folder, e)
foldersToDelete.push(folder)
foldersToDelete.push(folder.path)
}
}
if (foldersToDelete.length) {
const newFolders = openedFolders.filter((f: string) => !foldersToDelete.includes(f))
this.call('electronconfig', 'writeConfig', {recentFolders: newFolders})
const newFolders = recentFolders.filter((f: recentFolder) => !foldersToDelete.includes(f.path))
this.call('electronconfig', 'writeConfig', {recentFolders: deplucateFolderList(newFolders)})
}
}
createWindow()
@ -346,6 +355,7 @@ class FSPluginClient extends ElectronBasePluginClient {
path,
timestamp,
})
config.recentFolders = deplucateFolderList(config.recentFolders)
writeConfig(config)
}

Loading…
Cancel
Save