From 47ba520c2422d8e4842468a32ca13492845183cd Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Sat, 10 Nov 2018 21:22:44 -0800 Subject: [PATCH] Add method to reopen Webamp --- js/actionCreators/index.ts | 5 +++++ js/actionTypes.ts | 1 + js/reducers/display.ts | 3 +++ js/types.ts | 3 +++ js/webampLazy.tsx | 4 ++++ 5 files changed, 16 insertions(+) diff --git a/js/actionCreators/index.ts b/js/actionCreators/index.ts index a1881025..f81b2273 100644 --- a/js/actionCreators/index.ts +++ b/js/actionCreators/index.ts @@ -1,5 +1,6 @@ import { CLOSE_WINAMP, + OPEN_WINAMP, STOP, TOGGLE_VISUALIZER_STYLE, CLOSE_REQUESTED, @@ -108,6 +109,10 @@ export function close(): Dispatchable { }; } +export function open(): Dispatchable { + return { type: OPEN_WINAMP }; +} + export function toggleVisualizerStyle(): Dispatchable { return { type: TOGGLE_VISUALIZER_STYLE }; } diff --git a/js/actionTypes.ts b/js/actionTypes.ts index f8e476cf..891a82f7 100644 --- a/js/actionTypes.ts +++ b/js/actionTypes.ts @@ -1,5 +1,6 @@ export const ADD_TRACK_FROM_URL = "ADD_TRACK_FROM_URL"; export const CLOSE_WINAMP = "CLOSE_WINAMP"; +export const OPEN_WINAMP = "OPEN_WINAMP"; export const MINIMIZE_WINAMP = "MINIMIZE_WINAMP"; export const IS_PLAYING = "IS_PLAYING"; export const IS_STOPPED = "IS_STOPPED"; diff --git a/js/reducers/display.ts b/js/reducers/display.ts index b9c55634..09726e27 100644 --- a/js/reducers/display.ts +++ b/js/reducers/display.ts @@ -12,6 +12,7 @@ import { createSelector } from "reselect"; import { CLOSE_WINAMP, + OPEN_WINAMP, SET_SKIN_DATA, START_WORKING, STEP_MARQUEE, @@ -143,6 +144,8 @@ const display = ( return { ...state, working: true }; case CLOSE_WINAMP: return { ...state, closed: true }; + case OPEN_WINAMP: + return { ...state, closed: false }; case LOADING: return { ...state, loading: true }; case LOADED: diff --git a/js/types.ts b/js/types.ts index fa40443b..b8ee0f88 100644 --- a/js/types.ts +++ b/js/types.ts @@ -253,6 +253,9 @@ export type Action = | { type: "CLOSE_WINAMP"; } + | { + type: "OPEN_WINAMP"; + } | { type: "LOADING"; } diff --git a/js/webampLazy.tsx b/js/webampLazy.tsx index 3c057815..49162bfb 100644 --- a/js/webampLazy.tsx +++ b/js/webampLazy.tsx @@ -307,6 +307,10 @@ class Winamp { return this._actionEmitter.on(CLOSE_WINAMP, cb); } + reopen(): void { + this.store.dispatch(Actions.open()); + } + onTrackDidChange(cb: (trackInfo: LoadedURLTrack | null) => void): () => void { let previousTrackId: number | null = null; return this.store.subscribe(() => {