A music player that connects to your cloud/distributed storage.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: refactor

+16 -16
+16 -16
src/components/orchestrator/process-tracks/element.js
··· 28 28 class ProcessTracksOrchestrator extends DiffuseElement { 29 29 #process; 30 30 31 - /** @type {Promise<{ input: Worker | SharedWorker; metadataProcessor: Worker | SharedWorker } | undefined>} */ 32 - #workers = Promise.resolve(undefined); 31 + /** @type {Promise<{ input: Worker | SharedWorker; metadataProcessor: Worker | SharedWorker }> | undefined} */ 32 + #workers = undefined; 33 33 34 34 static NAME = "diffuse/orchestrator/process-tracks"; 35 35 static WORKER_URL = "components/orchestrator/process-tracks/worker.js"; ··· 60 60 super.connectedCallback(); 61 61 62 62 /** @type {InputElement} */ 63 - this.input = query(this, "input-selector"); 63 + const input = query(this, "input-selector"); 64 64 65 65 /** @type {OutputElement<Track[]>} */ 66 - this.output = query(this, "output-selector"); 66 + const output = query(this, "output-selector"); 67 67 68 68 /** @type {import("@components/processor/metadata/element.js").CLASS} */ 69 - this.metadataProcessor = query(this, "metadata-processor-selector"); 69 + const metadataProcessor = query(this, "metadata-processor-selector"); 70 + 71 + // Assign to self 72 + this.input = input; 73 + this.output = output; 74 + this.metadataProcessor = metadataProcessor; 70 75 71 76 // Create new workers specially for track processing 72 77 this.#workers = Promise.all([ 73 - customElements.whenDefined(this.input.localName), 74 - customElements.whenDefined(this.metadataProcessor.localName), 78 + customElements.whenDefined(input.localName), 79 + customElements.whenDefined(metadataProcessor.localName), 75 80 ]).then(() => { 76 - if (!this.input) return undefined; 77 - if (!this.metadataProcessor) return undefined; 78 - 79 81 return { 80 - input: this.input.worker(), 81 - metadataProcessor: this.metadataProcessor.worker(), 82 + input: input.worker(), 83 + metadataProcessor: metadataProcessor.worker(), 82 84 }; 83 85 }); 84 86 85 87 // Wait until defined 86 - await customElements.whenDefined(this.output.localName); 88 + await customElements.whenDefined(output.localName); 87 89 88 90 // Process whenever tracks are initially loaded 89 91 this.effect(() => { 90 - if (!this.output) return; 91 - 92 - const state = this.output.tracks.state(); 92 + const state = output.tracks.state(); 93 93 if (state !== "loaded") return; 94 94 95 95 untracked(() => this.process());