diff web/light9-timeline-audio.ts @ 2439:06da5db2fafe

rewrite ascoltami to use the graph for more playback data
author drewp@bigasterisk.com
date Thu, 30 May 2024 01:08:07 -0700
parents 4556eebe5d73
children e7e03c203c99
line wrap: on
line diff
--- a/web/light9-timeline-audio.ts	Wed May 29 17:28:25 2024 -0700
+++ b/web/light9-timeline-audio.ts	Thu May 30 01:08:07 2024 -0700
@@ -27,6 +27,7 @@
 @customElement("light9-timeline-audio")
 export class Light9TimelineAudio extends LitElement {
   graph!: SyncedGraph;
+  graphReady: Promise<void>;
   render() {
     return html`
       <style>
@@ -62,15 +63,17 @@
   constructor() {
     super();
 
-    getTopGraph().then((g) => {
+    this.graphReady = getTopGraph().then((g) => {
       this.graph = g;
     });
   }
 
-  updated(changedProperties: PropertyValues) {
+  async updated(changedProperties: PropertyValues) {
+    super.updated(changedProperties);
     if (changedProperties.has("song") || changedProperties.has("show")) {
+      await this.graphReady;
       if (this.song && this.show) {
-        this.graph.runHandler(this.setImgSrc.bind(this), "timeline-audio " + this.song);
+        this.graph.runHandler(this.setImgSrc.bind(this), "timeline-audio " + this.song.value);
       }
     }
     if (changedProperties.has("zoom")) {