mirror of
https://github.com/FJurmanovic/wallet-web.git
synced 2026-11-11 07:41:09 +00:00
fixed architecture to dispatch events when routes and token changes
This commit is contained in:
@@ -21,13 +21,15 @@ class AppLinkElement extends HTMLElement {
|
||||
this.routerService = this.appMain?.routerService;
|
||||
this.update();
|
||||
if (isTrue(this.goBack)) {
|
||||
window.addEventListener("routechanged", () => {
|
||||
this.update();
|
||||
});
|
||||
window.addEventListener("routechanged", this.update);
|
||||
}
|
||||
}
|
||||
|
||||
public disconnectedCallback(): void {}
|
||||
public disconnectedCallback(): void {
|
||||
if (isTrue(this.goBack)) {
|
||||
window.removeEventListener("routechanged", this.update);
|
||||
}
|
||||
}
|
||||
|
||||
goTo = () => {
|
||||
if (!isTrue(this.goBack) && this.to) {
|
||||
@@ -55,7 +57,7 @@ class AppLinkElement extends HTMLElement {
|
||||
>`}`;
|
||||
}
|
||||
|
||||
update() {
|
||||
update = () => {
|
||||
render(this.render(), this);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -27,11 +27,12 @@ class AppMainElement extends HTMLElement {
|
||||
path: "/",
|
||||
component: "home-page",
|
||||
layout: "menu-layout",
|
||||
middleware: this.middleAuth,
|
||||
},
|
||||
{
|
||||
path: "/home",
|
||||
component: "home-page",
|
||||
layout: "menu-layout",
|
||||
middleware: this.middleAuth,
|
||||
},
|
||||
{
|
||||
path: "/register",
|
||||
@@ -46,10 +47,16 @@ class AppMainElement extends HTMLElement {
|
||||
{
|
||||
path: "/unauthorized",
|
||||
component: "login-page",
|
||||
layout: "menu-layout",
|
||||
},
|
||||
{
|
||||
path: "token-expired",
|
||||
path: "/token-expired",
|
||||
component: "login-page",
|
||||
layout: "menu-layout",
|
||||
},
|
||||
{
|
||||
path: "/logout",
|
||||
component: "logout-page",
|
||||
},
|
||||
]);
|
||||
this.routerService.init();
|
||||
|
||||
Reference in New Issue
Block a user