mirror of
https://github.com/FJurmanovic/wallet-web.git
synced 2026-02-06 14:18:08 +00:00
fixed architecture to dispatch events when routes and token changes
This commit is contained in:
@@ -11,10 +11,16 @@ class HomePageElement extends HTMLElement {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
@update
|
||||
|
||||
connectedCallback() {
|
||||
this.pingService = new PingService(this.appMain?.appService);
|
||||
if (this.appMain.isAuth) this.getPong();
|
||||
this.update();
|
||||
window.addEventListener("tokenchange", this.update);
|
||||
}
|
||||
|
||||
disconnectedCallback(): void {
|
||||
window.removeEventListener("tokenchange", this.update);
|
||||
}
|
||||
|
||||
getPong = async () => {
|
||||
@@ -31,13 +37,21 @@ class HomePageElement extends HTMLElement {
|
||||
|
||||
render() {
|
||||
return html`
|
||||
<app-link data-to="/home" data-title="Home"></app-link> |
|
||||
<app-link data-to="/" data-title="Main"></app-link> |
|
||||
<app-link data-to="/login" data-title="Login"></app-link>
|
||||
${this.appMain.isAuth
|
||||
? html`<app-link data-to="/home" data-title="Home"></app-link>
|
||||
|<app-link
|
||||
data-to="/logout"
|
||||
data-title="Logout"
|
||||
></app-link>`
|
||||
: html`<app-link
|
||||
data-to="/login"
|
||||
data-title="Login"
|
||||
></app-link>`}
|
||||
`;
|
||||
}
|
||||
|
||||
update() {
|
||||
update = () => {
|
||||
render(this.render(), this);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user