Unsubscribe to package topic (#634)

* bump 0.3.0

* bump v0.2.20

* #451 unsubscribe to package topic on uninstall

* cleanup
This commit is contained in:
Neil 2023-05-30 09:40:28 +08:00 committed by GitHub
parent 0d9ac5e30e
commit 7c63a1f570
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -20,6 +20,7 @@ import { getAutoUpdateStatus, getUpdater, isDev } from "./auto-updater";
import { loadPackageCache, writePackageCache } from "./package";
import { nanoid } from "nanoid";
import { MainWindowNotifier } from "./types";
import { unsubscribeToPackageTopic } from "./push-notification";
export type HandlerOptions = {
// A function to call back to the current main
@ -160,6 +161,10 @@ export default function initializeHandlers({ notifyMainWindow }: HandlerOptions)
try {
log.info("deleting package:", fullName);
await deletePackageFolder(fullName, version);
const { installed_versions } = await getInstalledVersionsForPackage(fullName);
if (installed_versions.length === 0) {
await unsubscribeToPackageTopic(fullName);
}
} catch (e) {
log.error(e);
} finally {