Notate some places where we have known bugs

This commit is contained in:
Jordan Eldredge 2019-04-07 12:37:03 -07:00
parent 282cd6444e
commit 80f34157dd
5 changed files with 16 additions and 0 deletions

View file

@ -63,7 +63,9 @@ class App extends React.Component<Props> {
_webampNode: HTMLDivElement | null;
constructor(props: Props) {
super(props);
// TODO #leak
this._emitter = new Emitter();
// TODO #leak
this._bindings = {};
this._webampNode = null;
}

View file

@ -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) {
//
}

View file

@ -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();

View file

@ -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],
});

View file

@ -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<void> {
// 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<void> {
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");
}