Skip to content

Commit d71fb79

Browse files
committed
fix plugin uninstall dialog issues
1 parent 107b9ab commit d71fb79

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

backend/decky_loader/browser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ async def uninstall_plugin(self, name: str):
135135
# logger.debug("current plugins: %s", snapshot_string)
136136
if name in self.plugins:
137137
logger.debug("Plugin %s was found", name)
138-
self.plugins[name].stop(uninstall=True)
138+
await self.plugins[name].stop(uninstall=True)
139139
logger.debug("Plugin %s was stopped", name)
140140
del self.plugins[name]
141141
logger.debug("Plugin %s was removed from the dictionary", name)
@@ -249,15 +249,15 @@ async def _install(self, artifact: str, name: str, version: str, hash: str):
249249
if ret:
250250
logger.info(f"Installed {name} (Version: {version})")
251251
if name in self.loader.plugins:
252-
self.loader.plugins[name].stop()
252+
await self.loader.plugins[name].stop()
253253
self.loader.plugins.pop(name, None)
254254
await sleep(1)
255255
if not isInstalled:
256256
current_plugin_order = self.settings.getSetting("pluginOrder")
257257
current_plugin_order.append(name)
258258
self.settings.setSetting("pluginOrder", current_plugin_order)
259259
logger.debug("Plugin %s was added to the pluginOrder setting", name)
260-
self.loader.import_plugin(path.join(plugin_dir, "main.py"), plugin_folder)
260+
await self.loader.import_plugin(path.join(plugin_dir, "main.py"), plugin_folder)
261261
else:
262262
logger.fatal(f"Failed Downloading Remote Binaries")
263263
else:

backend/decky_loader/loader.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ async def handle_frontend_bundle(self, request: web.Request):
140140
with open(path.join(self.plugin_path, plugin.plugin_directory, "dist/index.js"), "r", encoding="utf-8") as bundle:
141141
return web.Response(text=bundle.read(), content_type="application/javascript")
142142

143-
def import_plugin(self, file: str, plugin_directory: str, refresh: bool | None = False, batch: bool | None = False):
143+
async def import_plugin(self, file: str, plugin_directory: str, refresh: bool | None = False, batch: bool | None = False):
144144
try:
145145
async def plugin_emitted_event(event: str, args: Any):
146146
self.logger.debug(f"PLUGIN EMITTED EVENT: {event} with args {args}")
@@ -152,7 +152,7 @@ async def plugin_emitted_event(event: str, args: Any):
152152
self.logger.info(f"Plugin {plugin.name} is already loaded and has requested to not be re-loaded")
153153
return
154154
else:
155-
self.plugins[plugin.name].stop()
155+
await self.plugins[plugin.name].stop()
156156
self.plugins.pop(plugin.name, None)
157157
if plugin.passive:
158158
self.logger.info(f"Plugin {plugin.name} is passive")
@@ -168,18 +168,18 @@ async def plugin_emitted_event(event: str, args: Any):
168168
async def dispatch_plugin(self, name: str, version: str | None, load_type: int = PluginLoadType.ESMODULE_V1.value):
169169
await self.ws.emit("loader/import_plugin", name, version, load_type)
170170

171-
def import_plugins(self):
171+
async def import_plugins(self):
172172
self.logger.info(f"import plugins from {self.plugin_path}")
173173

174174
directories = [i for i in listdir(self.plugin_path) if path.isdir(path.join(self.plugin_path, i)) and path.isfile(path.join(self.plugin_path, i, "plugin.json"))]
175175
for directory in directories:
176176
self.logger.info(f"found plugin: {directory}")
177-
self.import_plugin(path.join(self.plugin_path, directory, "main.py"), directory, False, True)
177+
await self.import_plugin(path.join(self.plugin_path, directory, "main.py"), directory, False, True)
178178

179179
async def handle_reloads(self):
180180
while True:
181181
args = await self.reload_queue.get()
182-
self.import_plugin(*args) # pyright: ignore [reportArgumentType]
182+
await self.import_plugin(*args) # pyright: ignore [reportArgumentType]
183183

184184
async def handle_plugin_method_call_legacy(self, plugin_name: str, method_name: str, kwargs: Dict[Any, Any]):
185185
res: Dict[Any, Any] = {}

backend/decky_loader/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ async def get_auth_token(self, request: Request):
101101
async def load_plugins(self):
102102
# await self.wait_for_server()
103103
logger.debug("Loading plugins")
104-
self.plugin_loader.import_plugins()
104+
await self.plugin_loader.import_plugins()
105105
if self.settings.getSetting("pluginOrder", None) == None:
106106
self.settings.setSetting("pluginOrder", list(self.plugin_loader.plugins.keys()))
107107
logger.debug("Did not find pluginOrder setting, set it to default")

backend/decky_loader/plugin/plugin.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,9 @@ def start(self):
108108
self._listener_task = create_task(self._response_listener())
109109
return self
110110

111-
def stop(self, uninstall: bool = False):
111+
async def stop(self, uninstall: bool = False):
112+
if hasattr(self, "_socket"):
113+
await self._socket.write_single_line(dumps({ "stop": True, "uninstall": uninstall }, ensure_ascii=False))
114+
await self._socket.close_socket_connection()
112115
if hasattr(self, "_listener_task"):
113-
self._listener_task.cancel()
114-
async def _(self: PluginWrapper):
115-
if hasattr(self, "_socket"):
116-
await self._socket.write_single_line(dumps({ "stop": True, "uninstall": uninstall }, ensure_ascii=False))
117-
await self._socket.close_socket_connection()
118-
create_task(_(self))
116+
self._listener_task.cancel()

frontend/src/components/modals/PluginUninstallModal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const PluginUninstallModal: FC<PluginUninstallModalProps> = ({ name, title, butt
2121
// we invalidate here so if you re-install it, you won't have an out-of-date hidden filter
2222
await DeckyPluginLoader.frozenPluginsService.invalidate();
2323
await DeckyPluginLoader.hiddenPluginsService.invalidate();
24+
closeModal?.();
2425
}}
2526
strTitle={title}
2627
strOKButtonText={buttonText}

0 commit comments

Comments
 (0)