Skip to content

Commit

Permalink
chore: add reinstall plugins CTA
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan committed Oct 6, 2023
1 parent 91d49d1 commit b8b7c41
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
12 changes: 12 additions & 0 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,18 @@ function handleIPCs() {
ipcMain.handle("relaunch", async (_event, url) => {
dispose(requiredModules);
app.relaunch();
app.exit();
});

ipcMain.handle("reloadPlugins", async (_event, url) => {
const userDataPath = app.getPath("userData");
const fullPath = join(userDataPath, "plugins");

rmdir(fullPath, { recursive: true }, function (err) {
if (err) console.log(err);
app.relaunch();
app.exit();
});
});

/**
Expand Down
2 changes: 2 additions & 0 deletions electron/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ contextBridge.exposeInMainWorld("electronAPI", {

pluginPath: () => ipcRenderer.invoke("pluginPath"),

reloadPlugins: () => ipcRenderer.invoke("reloadPlugins"),

appVersion: () => ipcRenderer.invoke("appVersion"),

openExternalUrl: (url: string) => ipcRenderer.invoke("openExternalUrl", url),
Expand Down
33 changes: 24 additions & 9 deletions web/app/_components/Preferences.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,30 @@ export const Preferences = () => {
/>
</label>
</div>
<button
type="submit"
className={classNames(
"rounded-md px-3.5 py-2.5 text-sm font-semibold text-white shadow-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600",
fileName ? "bg-indigo-600 hover:bg-indigo-500" : "bg-gray-500"
)}
>
Install Plugin
</button>
<div className="flex flex-col space-y-2">
<button
type="submit"
className={classNames(
"rounded-md px-3.5 py-2.5 text-sm font-semibold text-white shadow-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600",
fileName
? "bg-blue-500 hover:bg-blue-300"
: "bg-gray-500"
)}
>
Install Plugin
</button>

<button
className={classNames(
"bg-blue-500 hover:bg-blue-300 rounded-md px-3.5 py-2.5 text-sm font-semibold text-white shadow-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
)}
onClick={() => {
window.electronAPI.reloadPlugins();
}}
>
Reload Plugins
</button>
</div>
</div>
</form>

Expand Down

0 comments on commit b8b7c41

Please sign in to comment.