From 80f34157ddce6a286a6c71b1e395b453c4f42b5a Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Sun, 7 Apr 2019 12:37:03 -0700 Subject: [PATCH] Notate some places where we have known bugs --- js/components/App.tsx | 2 ++ js/media/elementSource.ts | 6 ++++++ js/media/index.ts | 2 ++ js/store.ts | 1 + js/webampLazy.tsx | 5 +++++ 5 files changed, 16 insertions(+) diff --git a/js/components/App.tsx b/js/components/App.tsx index 21222e46..6ca70a17 100644 --- a/js/components/App.tsx +++ b/js/components/App.tsx @@ -63,7 +63,9 @@ class App extends React.Component { _webampNode: HTMLDivElement | null; constructor(props: Props) { super(props); + // TODO #leak this._emitter = new Emitter(); + // TODO #leak this._bindings = {}; this._webampNode = null; } diff --git a/js/media/elementSource.ts b/js/media/elementSource.ts index b48bd88e..28e4a02f 100644 --- a/js/media/elementSource.ts +++ b/js/media/elementSource.ts @@ -25,25 +25,30 @@ export default class ElementSource { this._stalled = false; this._status = MEDIA_STATUS.STOPPED; + // TODO: #leak this._audio.addEventListener("suspend", () => { this._setStalled(true); }); + // TODO: #leak this._audio.addEventListener("durationchange", () => { this._emitter.trigger("loaded"); this._setStalled(false); }); + // TODO: #leak this._audio.addEventListener("ended", () => { this._emitter.trigger("ended"); this._setStatus(MEDIA_STATUS.STOPPED); }); // TODO: Throttle to 50 (if needed) + // TODO: #leak this._audio.addEventListener("timeupdate", () => { this._emitter.trigger("positionChange"); }); + // TODO: #leak this._audio.addEventListener("error", e => { switch (this._audio.error!.code) { case 1: @@ -99,6 +104,7 @@ export default class ElementSource { } try { await this._audio.play(); + // TODO #race } catch (err) { // } diff --git a/js/media/index.ts b/js/media/index.ts index 420ad72d..9c520de1 100644 --- a/js/media/index.ts +++ b/js/media/index.ts @@ -32,6 +32,7 @@ export default class Media { // https://developers.google.com/web/updates/2017/09/autoplay-policy-changes // https://gist.github.com/laziel/7aefabe99ee57b16081c // Via: https://stackoverflow.com/a/43395068/1263117 + // TODO #leak if (this._context.state === "suspended") { const resume = async () => { await this._context.resume(); @@ -231,6 +232,7 @@ export default class Media { async loadFromUrl(url: string, autoPlay: boolean) { this._emitter.trigger("waiting"); await this._source.loadUrl(url); + // TODO #race this._emitter.trigger("stopWaiting"); if (autoPlay) { this.play(); diff --git a/js/store.ts b/js/store.ts index 6eef1a5b..1b0d4010 100644 --- a/js/store.ts +++ b/js/store.ts @@ -9,6 +9,7 @@ import Media from "./media"; import Emitter from "./emitter"; import { Extras, Dispatch, Action, AppState, Middleware } from "./types"; +// TODO: Move to demo const compose = composeWithDevTools({ actionsBlacklist: [UPDATE_TIME_ELAPSED, STEP_MARQUEE], }); diff --git a/js/webampLazy.tsx b/js/webampLazy.tsx index 54019231..41217e3c 100644 --- a/js/webampLazy.tsx +++ b/js/webampLazy.tsx @@ -127,6 +127,7 @@ interface PrivateOptions { } // Return a promise that resolves when the store matches a predicate. +// TODO #leak const storeHas = ( store: Store, predicate: (state: AppState) => boolean @@ -366,6 +367,7 @@ class Winamp { onTrackDidChange(cb: (trackInfo: LoadedURLTrack | null) => void): () => void { let previousTrackId: number | null = null; + // TODO #leak return this.store.subscribe(() => { const state = this.store.getState(); const trackId = Selectors.getCurrentlyPlayingTrackIdIfLoaded(state); @@ -383,6 +385,7 @@ class Winamp { async skinIsLoaded(): Promise { // Wait for the skin to load. + // TODO #leak return storeHas(this.store, state => !state.display.loading); } @@ -395,12 +398,14 @@ class Winamp { } __onStateChange(cb: () => void): () => void { + // TODO #leak return this.store.subscribe(cb); } async renderWhenReady(node: HTMLElement): Promise { this.store.dispatch(Actions.centerWindowsInContainer(node)); await this.skinIsLoaded(); + // TODO #race We may have been destroyed if (this._node != null) { throw new Error("Cannot render a Webamp instance twice"); }