Sketch out open/close window methods

This commit is contained in:
Jordan Eldredge 2020-11-01 14:29:21 -08:00
parent 9d4f71546a
commit 1fead0799d
6 changed files with 33 additions and 0 deletions

View file

@ -30,6 +30,7 @@ export {
toggleDoubleSizeMode,
toggleEqualizerShadeMode,
togglePlaylistShadeMode,
openWindow,
closeWindow,
hideWindow,
showWindow,

View file

@ -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 };
}

View file

@ -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";

View file

@ -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,

View file

@ -383,6 +383,10 @@ export type Action =
type: "CLOSE_WINDOW";
windowId: WindowId;
}
| {
type: "OPEN_WINDOW";
windowId: WindowId;
}
| {
type: "SET_WINDOW_VISIBILITY";
windowId: WindowId;

View file

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