Skip to content

Commit 6d47a54

Browse files
committed
small update
1 parent 6abf8f6 commit 6d47a54

File tree

3 files changed

+18
-21
lines changed

3 files changed

+18
-21
lines changed

client/index.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,7 @@ <h1 class="error-title">Unable to Load Dust</h1>
240240

241241
<!-- Main Application Container -->
242242
<div id="app">
243-
<!-- The Dust application will be mounted here -->
244-
<dust-app></dust-app>
243+
<!-- The Dust application will be mounted here by main.js -->
245244
</div>
246245

247246
<!-- Application Initialization Script -->
@@ -292,7 +291,7 @@ <h1 class="error-title">Unable to Load Dust</h1>
292291
document.addEventListener('DOMContentLoaded', async () => {
293292
try {
294293
// Wait for custom elements to be defined
295-
await customElements.whenDefined('dust-app');
294+
await customElements.whenDefined('dust-main');
296295

297296
// Small delay to ensure everything is properly rendered
298297
await new Promise(resolve => setTimeout(resolve, 100));

client/src/components/dust-app.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ export class DustApp extends LitElement {
3434
@property({ attribute: false })
3535
appStateService!: AppStateService;
3636

37-
@property({ type: Object })
38-
appState!: AppState;
37+
@state()
38+
private appState!: AppState;
3939

4040
@state()
4141
private currentPage = "library";
@@ -46,7 +46,7 @@ export class DustApp extends LitElement {
4646
@state()
4747
private currentGenreId: number | null = null;
4848

49-
// Removed unused state variable
49+
private unsubscribe?: () => void;
5050

5151
static styles = css`
5252
:host {
@@ -142,6 +142,15 @@ export class DustApp extends LitElement {
142142
connectedCallback() {
143143
console.log("DustApp - connected callback");
144144
super.connectedCallback();
145+
146+
// Initialize app state from service
147+
this.appState = this.appStateService.getState();
148+
149+
// Subscribe to state changes
150+
this.unsubscribe = this.appStateService.subscribe(() => {
151+
this.appState = this.appStateService.getState();
152+
});
153+
145154
window.addEventListener("popstate", this.handleNavigation);
146155
this.handleNavigation();
147156

@@ -152,6 +161,7 @@ export class DustApp extends LitElement {
152161
disconnectedCallback() {
153162
console.log("DustApp - disconnected callback");
154163
super.disconnectedCallback();
164+
this.unsubscribe?.();
155165
window.removeEventListener("popstate", this.handleNavigation);
156166
}
157167

client/src/main.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
*/
44

55
import { LitElement, html, css } from "lit";
6-
import { customElement, state } from "lit/decorators.js";
6+
import { customElement } from "lit/decorators.js";
77
import { provide } from "@lit/context";
88

99
import { appState, appStateContext } from "./services/app-state.js";
10-
import type { AppState } from "./types/app.js";
1110

1211
// Import components
1312
import "./components/dust-app.js";
@@ -17,8 +16,7 @@ export class DustMain extends LitElement {
1716
@provide({ context: appStateContext })
1817
appStateService = appState;
1918

20-
@state()
21-
private appState: AppState = appState.getState();
19+
// App state is managed by the dust-app component directly
2220

2321
static styles = css`
2422
:host {
@@ -32,20 +30,10 @@ export class DustMain extends LitElement {
3230
connectedCallback() {
3331
console.log("DustMain - connected callback");
3432
super.connectedCallback();
35-
this.unsubscribe = appState.subscribe(() => {
36-
this.appState = appState.getState();
37-
});
3833
}
3934

40-
disconnectedCallback() {
41-
super.disconnectedCallback();
42-
this.unsubscribe?.();
43-
}
44-
45-
private unsubscribe?: () => void;
46-
4735
render() {
48-
return html` <dust-app .appState=${this.appState}></dust-app> `;
36+
return html` <dust-app></dust-app> `;
4937
}
5038
}
5139

0 commit comments

Comments
 (0)