Skip to content

Commit

Permalink
made Uninstall not refresh if they cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
matryer committed Mar 10, 2021
1 parent f5cef13 commit c5aab48
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
6 changes: 5 additions & 1 deletion app/frontend/src/InstalledPluginView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@
function onUninstallClick() {
const done = wait()
uninstallPlugin(installedPlugin)
.then(() => {
.then((result) => {
if (result === false) {
// canceled
return
}
clearNav()
location.hash = ''
refreshInstalledPlugins(installedPlugins)
Expand Down
9 changes: 8 additions & 1 deletion app/frontend/src/backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ const backend = {
},
}
"CommandService": {
/**
* ClearCache
* @returns {Promise}
*/
"ClearCache": () => {
return window.backend.main.CommandService.ClearCache();
},
/**
* OpenFile
* @param {string} arg1 - Go Type: string
Expand Down Expand Up @@ -155,7 +162,7 @@ const backend = {
/**
* UninstallPlugin
* @param {any} arg1 - Go Type: main.UninstallPluginRequest
* @returns {Promise<Error>} - Go Type: error
* @returns {Promise<boolean|Error>} - Go Type: bool
*/
"UninstallPlugin": (arg1) => {
return window.backend.main.PluginsService.UninstallPlugin(arg1);
Expand Down
8 changes: 4 additions & 4 deletions app/plugins_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ type UninstallPluginRequest struct {
}

// UninstallPlugin removes a plugin.
func (p *PluginsService) UninstallPlugin(installedPluginInfo UninstallPluginRequest) error {
func (p *PluginsService) UninstallPlugin(installedPluginInfo UninstallPluginRequest) (bool, error) {
defer p.OnRefresh()
p.osLock.Lock()
defer p.osLock.Unlock()
Expand All @@ -201,18 +201,18 @@ func (p *PluginsService) UninstallPlugin(installedPluginInfo UninstallPluginRequ
case "Uninstall":
// continue
case "Cancel":
return nil
return false, nil
}
}
installer := &plugins.Installer{
PluginDir: pluginDirectory,
}
err := installer.Uninstall(installedPluginInfo.Path)
if err != nil {
return errors.Wrap(err, "uninstall")
return false, errors.Wrap(err, "uninstall")
}
tickOS() // wait a beat
return nil
return true, nil
}

// InstalledPluginMetadata is the metadata extracted from an installed
Expand Down

0 comments on commit c5aab48

Please sign in to comment.