#255 package install notification (#292)

Co-authored-by: neil <neil@neils-MacBook-Pro.local>
This commit is contained in:
Neil 2023-03-13 17:28:40 +08:00 committed by GitHub
parent caffd2f347
commit 9ddfd15477
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View file

@ -6,7 +6,7 @@
import type { GUIPackage } from '$libs/types';
import { PackageStates } from '$libs/types';
import { getPackage } from '@native';
import { inc } from 'semver';
import { notificationStore } from '$libs/stores';
export let pkg: GUIPackage;
@ -56,6 +56,9 @@
await onClick();
await new Promise((resolve) => {
setTimeout(() => {
notificationStore.add({
message: `Package ${pkg.full_name} v${pkg.version} has been installed.`,
});
clearTimeout(fakeTimer);
fakeLoadingProgress = 100;
resolve(null);

View file

@ -38,6 +38,19 @@ export default function initNotificationStore() {
return {
notifications,
subscribe,
remove
remove,
add: (partialNotification: Partial<Notification>) => {
if (!partialNotification.message) throw new Error("message is required");
const notification: Notification = {
id: nanoid(4),
i18n_key: partialNotification.i18n_key || "",
type: NotificationType.MESSAGE,
message: partialNotification.message || "",
...partialNotification
};
update((values) => [notification, ...values]);
}
};
}