diff --git a/example/ui/src/applet-main.ts b/example/ui/src/applet-main.ts index 168e9333..ff1be5b8 100644 --- a/example/ui/src/applet-main.ts +++ b/example/ui/src/applet-main.ts @@ -13,6 +13,7 @@ import { weaveUrlToLocation, ReadonlyPeerStatusStore, GroupPermissionType, + UnsubscribeFunction, } from '@theweave/api'; import { AgentPubKey, AppClient } from '@holochain/client'; import '@theweave/elements/dist/elements/wal-embed.js'; @@ -78,11 +79,28 @@ export class AppletMain extends LitElement { // @state() // unsubscribe: undefined | (() => void); + @query('#failUnbeforeUnloadCheckmark') + failUnbeforeUnloadCheckmark!: HTMLInputElement; + + onBeforeUnloadUnsubscribe: UnsubscribeFunction | undefined; + async firstUpdated() { + this.onBeforeUnloadUnsubscribe = this.weaveClient.onBeforeUnload(() => { + if (this.failUnbeforeUnloadCheckmark.checked) + throw new Error( + 'The onbeforeunload callback failed (intentionally for testing purposes) in the example applet :(.' + ); + console.log('@example-applet: Running second unbeforeunload callback.'); + }); + this.groupPermissionType = await this.weaveClient.myGroupPermissionType(); this.appletParticipants = await this.weaveClient.appletParticipants(); } + disconnectedCallback(): void { + if (this.onBeforeUnloadUnsubscribe) this.onBeforeUnloadUnsubscribe(); + } + // disconnectedCallback(): void { // if (this.unsubscribe) this.unsubscribe(); // } @@ -247,6 +265,7 @@ export class AppletMain extends LitElement {
+

Notifications

@@ -256,6 +275,17 @@ export class AppletMain extends LitElement { + +

on-before-unload behavior

+ +
+ + Make the on-before-unload callback fail when reloading the applet to test how Moss handles this case. +
+ + +

Activity Notification

+ @@ -265,6 +295,9 @@ export class AppletMain extends LitElement { }}> Send Activity Notification + +

Links

+
Enter WAL: