mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-25 19:13:54 +00:00
Convert media reducer to Typescript
This commit is contained in:
parent
40fc9aad59
commit
dcf07f60c0
2 changed files with 58 additions and 1 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import { MediaState, Action } from "../types";
|
||||
import {
|
||||
PLAY,
|
||||
STOP,
|
||||
|
|
@ -16,7 +17,7 @@ import {
|
|||
} from "../actionTypes";
|
||||
import { TIME_MODE, MEDIA_STATUS } from "../constants";
|
||||
|
||||
const media = (state, action) => {
|
||||
const media = (state: MediaState, action: Action): MediaState => {
|
||||
if (!state) {
|
||||
return {
|
||||
timeMode: TIME_MODE.ELAPSED,
|
||||
56
js/types.ts
56
js/types.ts
|
|
@ -13,6 +13,48 @@ export type Action =
|
|||
| {
|
||||
type: "SET_AVAILABLE_SKINS";
|
||||
skins: Array<Skin>;
|
||||
}
|
||||
| {
|
||||
type: "PLAY";
|
||||
}
|
||||
| {
|
||||
type: "IS_PLAYING";
|
||||
}
|
||||
| {
|
||||
type: "PAUSE";
|
||||
}
|
||||
| {
|
||||
type: "STOP";
|
||||
}
|
||||
| {
|
||||
type: "IS_STOPPED";
|
||||
}
|
||||
| {
|
||||
type: "CHANNEL_COUNT_CHANGED";
|
||||
channels: number;
|
||||
} | {
|
||||
type: "TOGGLE_TIME_MODE";
|
||||
} | {
|
||||
type: "UPDATE_TIME_ELAPSED";
|
||||
elapsed: number;
|
||||
} | {
|
||||
type: "ADD_TRACK_FROM_URL";
|
||||
} | {
|
||||
type: "SET_MEDIA";
|
||||
length: number;
|
||||
kbps: number;
|
||||
khz: number;
|
||||
channels: number;
|
||||
} | {
|
||||
type: "SET_VOLUME";
|
||||
volume: number;
|
||||
} | {
|
||||
type: "SET_BALANCE";
|
||||
balance: number;
|
||||
} | {
|
||||
type: "TOGGLE_REPEAT";
|
||||
} | {
|
||||
type: "TOGGLE_SHUFFLE";
|
||||
};
|
||||
|
||||
export interface SettingsState {
|
||||
|
|
@ -22,3 +64,17 @@ export interface SettingsState {
|
|||
export interface NetworkState {
|
||||
connected: boolean;
|
||||
}
|
||||
|
||||
export interface MediaState {
|
||||
timeMode: string; // TODO: Convert this to an enum
|
||||
timeElapsed: number;
|
||||
length: number | null;
|
||||
kbps: number| null;
|
||||
khz: number | null;
|
||||
volume: number;
|
||||
balance: number;
|
||||
channels: number | null; // TODO: Convert this to an enum
|
||||
shuffle: boolean;
|
||||
repeat: boolean;
|
||||
status: string | null; // TODO: Convert this to an enum
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue