From 1fead0799d275cd9053b05efc0d89455e554381d Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Sun, 1 Nov 2020 14:29:21 -0800 Subject: [PATCH] Sketch out open/close window methods --- packages/webamp/js/actionCreators/index.ts | 1 + packages/webamp/js/actionCreators/windows.ts | 5 +++++ packages/webamp/js/actionTypes.ts | 1 + packages/webamp/js/reducers/windows.ts | 13 +++++++++++++ packages/webamp/js/types.ts | 4 ++++ packages/webamp/js/webampLazy.tsx | 9 +++++++++ 6 files changed, 33 insertions(+) diff --git a/packages/webamp/js/actionCreators/index.ts b/packages/webamp/js/actionCreators/index.ts index f8595e7c..f9ef6554 100644 --- a/packages/webamp/js/actionCreators/index.ts +++ b/packages/webamp/js/actionCreators/index.ts @@ -30,6 +30,7 @@ export { toggleDoubleSizeMode, toggleEqualizerShadeMode, togglePlaylistShadeMode, + openWindow, closeWindow, hideWindow, showWindow, diff --git a/packages/webamp/js/actionCreators/windows.ts b/packages/webamp/js/actionCreators/windows.ts index ebdbe904..18553bf8 100644 --- a/packages/webamp/js/actionCreators/windows.ts +++ b/packages/webamp/js/actionCreators/windows.ts @@ -7,6 +7,7 @@ import { WINDOW_SIZE_CHANGED, TOGGLE_WINDOW, CLOSE_WINDOW, + OPEN_WINDOW, TOGGLE_WINDOW_SHADE_MODE, SET_WINDOW_VISIBILITY, BROWSER_WINDOW_SIZE_CHANGED, @@ -88,6 +89,10 @@ export function closeWindow(windowId: WindowId): Action { return { type: CLOSE_WINDOW, windowId }; } +export function openWindow(windowId: WindowId): Action { + return { type: OPEN_WINDOW, windowId }; +} + export function hideWindow(windowId: WindowId): Action { return { type: SET_WINDOW_VISIBILITY, windowId, hidden: true }; } diff --git a/packages/webamp/js/actionTypes.ts b/packages/webamp/js/actionTypes.ts index 2e129a1a..3a4e7064 100644 --- a/packages/webamp/js/actionTypes.ts +++ b/packages/webamp/js/actionTypes.ts @@ -55,6 +55,7 @@ export const SET_MEDIA_TAGS = "SET_MEDIA_TAGS"; export const SET_MEDIA_DURATION = "SET_MEDIA_DURATION"; export const TOGGLE_WINDOW = "TOGGLE_WINDOW"; export const CLOSE_WINDOW = "CLOSE_WINDOW"; +export const OPEN_WINDOW = "CLOSE_WINDOW"; export const MEDIA_TAG_REQUEST_INITIALIZED = "MEDIA_TAG_REQUEST_INITIALIZED"; export const MEDIA_TAG_REQUEST_FAILED = "MEDIA_TAG_REQUEST_FAILED"; export const NETWORK_CONNECTED = "NETWORK_CONNECTED"; diff --git a/packages/webamp/js/reducers/windows.ts b/packages/webamp/js/reducers/windows.ts index bbae8913..5533319a 100644 --- a/packages/webamp/js/reducers/windows.ts +++ b/packages/webamp/js/reducers/windows.ts @@ -4,6 +4,7 @@ import { SET_FOCUSED_WINDOW, TOGGLE_WINDOW, CLOSE_WINDOW, + OPEN_WINDOW, SET_WINDOW_VISIBILITY, UPDATE_WINDOW_POSITIONS, WINDOW_SIZE_CHANGED, @@ -171,6 +172,18 @@ const windows = ( }, }, }; + case OPEN_WINDOW: + return { + ...state, + genWindows: { + ...state.genWindows, + [action.windowId]: { + ...state.genWindows[action.windowId], + open: false, + hidden: false, + }, + }, + }; case SET_WINDOW_VISIBILITY: return { ...state, diff --git a/packages/webamp/js/types.ts b/packages/webamp/js/types.ts index a092f423..2b5d7e8e 100644 --- a/packages/webamp/js/types.ts +++ b/packages/webamp/js/types.ts @@ -383,6 +383,10 @@ export type Action = type: "CLOSE_WINDOW"; windowId: WindowId; } + | { + type: "OPEN_WINDOW"; + windowId: WindowId; + } | { type: "SET_WINDOW_VISIBILITY"; windowId: WindowId; diff --git a/packages/webamp/js/webampLazy.tsx b/packages/webamp/js/webampLazy.tsx index 7927a1dc..bd7cd315 100644 --- a/packages/webamp/js/webampLazy.tsx +++ b/packages/webamp/js/webampLazy.tsx @@ -11,6 +11,7 @@ import { WindowPosition, ButterchurnOptions, Action, + WindowId, } from "./types"; import getStore from "./store"; import App from "./components/App"; @@ -390,6 +391,14 @@ class Winamp { return this._actionEmitter.on(MINIMIZE_WINAMP, cb); } + closeWindow(id: WindowId) { + this.store.dispatch(Actions.closeWindow(id)); + } + + openWindow(id: WindowId) { + this.store.dispatch(Actions.openWindow(id)); + } + setSkinFromUrl(url: string): void { this.store.dispatch(Actions.setSkinFromUrl(url)); }