diff --git a/docs/i18n.md b/docs/i18n.md index 6d64ab53dc..c598b82945 100644 --- a/docs/i18n.md +++ b/docs/i18n.md @@ -33,6 +33,7 @@ - [tl](#tl) - [tr](#tr) - [vi](#vi) +- [yue_CN](#yue_CN) - [yue_HK](#yue_HK) - [zh_tw](#zh_tw) - [zh_YUE](#zh_YUE) @@ -1038,13 +1039,10 @@ ### album: - genre - play - - tracks ### app: - - dashboard - downloads - equalizer - - favorite-artists - plugins - visualizer @@ -1057,49 +1055,17 @@ - name - status -### favorite-artists: - - empty - - empty-help - - header - -### help: - - report - ### library: - album - filter-placeholder -### lyrics: - - by-artist - ### option-control: - autoradio - loop - mini-player - - shuffle ### playlists: - - add-selected-tracks-to-downloads - - add-selected-tracks-to-favorites - - add-selected-tracks-to-queue - album - - duration - - error-empty-data - - error-invalid-data - - error-open-file - - error-save-file - - export-button - - export-fail-title - - export-success-title - - header - - import-button - - import-fail-title - - import-success-title - - play-selected-tracks-now - - playlist-created - - playlist-exported - - tracks-selected-plural - - tracks-selected-singular ### plugins: - header @@ -1109,13 +1075,9 @@ ### search: - album - - clear-history - last-searches - you-can-search-for -### seekbar: - - segment-popup - ### settings: - api-url - autoradio @@ -1317,9 +1279,6 @@ - clear-history - you-can-search-for -### seekbar: - - segment-popup - ### settings: - api-url - autoradio @@ -1932,7 +1891,6 @@ ### app: - favorite-artists - - plugins - visualizer ### dashboard: @@ -2011,7 +1969,6 @@ - autoradio-craziness - developer - devtools - - downloads - downloads-count - downloads-dir - downloads-dir-button @@ -2215,76 +2172,19 @@ ## ja_JP -### album: - - download - - download-toast-content - - genre - - play - - queue - - tracks - - year - -### app: - - collection - - dashboard - - downloads - - equalizer - - favorite-albums - - favorite-artists - - favorite-tracks - - library - - lyrics - - main - - playlists - - plugins - - search - - settings - - visualizer - ### artist: - - count - - queue - - similar - - title - tour ### dashboard: - add-all - - artist - best - best-new-albums - best-new-tracks - - genres - - news - - playcounts - - popular-track-title - - title - - top ### downloads: - - clear - completion - - empty - - empty-help - - header - - name - - status - -### favorite-albums: - - empty - - empty-help - - header - -### favorite-artists: - - empty - - empty-help - - header ### favorites: - - artist - - empty - - empty-help - - header - title ### help: @@ -2500,68 +2400,16 @@ ## ko -### album: - - genre - - play - - tracks - - year - -### app: - - favorite-artists - ### dashboard: - add-all -### favorite-artists: - - empty - - empty-help - - header - -### option-control: - - mini-player - -### playlists: - - add-selected-tracks-to-downloads - - add-selected-tracks-to-favorites - - add-selected-tracks-to-queue - - album - - duration - - error-empty-data - - error-invalid-data - - error-open-file - - error-save-file - - export-button - - export-fail-title - - export-success-title - - header - - import-button - - import-fail-title - - import-success-title - - play-selected-tracks-now - - playlist-created - - playlist-exported - - tracks-selected-plural - - tracks-selected-singular - -### seekbar: - - segment-popup - ### settings: - api-url - github-title - http - lastfm-title - - mastodon-authorization-token-label - - mastodon-authorize - - mastodon-authorized - - mastodon-awaiting-authorization - mastodon-description - - mastodon-instance-label - - mastodon-post-format-description - - mastodon-post-format-label - mastodon-title - - streaming - - youtube ### track-popup: - add-to-favorite @@ -2749,270 +2597,22 @@ ## no_NO -### album: - - download - - download-toast-content - - download-toast-title - - error-load - - genre - - play - - queue - - tracks - - year - ### app: - - collection - - dashboard - - downloads - equalizer - - favorite-albums - - favorite-artists - - favorite-tracks - - library - - lyrics - - main - - playlists - - plugins - - search - - settings - - visualizer - -### artist: - - count - - queue - - similar - - title - - tour ### dashboard: - add-all - - artist - - best - - best-new-albums - - best-new-tracks - genres - - news - - playcounts - - popular-track-title - - title - - top - -### downloads: - - clear - - completion - - empty - - empty-help - - header - - name - - status - -### favorite-albums: - - empty - - empty-help - - header - -### favorite-artists: - - empty - - empty-help - - header - -### favorites: - - artist - - empty - - empty-help - - header - - title - -### help: - - about - - header - - released - - report - - thanks - -### input-dialog: - - cancel - -### library: - - add - - album - - artist - - empty - - empty-help - - filter-placeholder - - header - - no-search-results - - no-search-results-help - - title - -### lyrics: - - by-artist - - empty - - empty-help - - not-found - -### option-control: - - autoradio - - loop - - mini-player - - shuffle - -### player: - - next-button - - play-pause-button - - previous-button - -### playlists: - - add-selected-tracks-to-downloads - - add-selected-tracks-to-favorites - - add-selected-tracks-to-queue - - album - - artist - - delete - - dialog-placeholder - - duration - - empty - - empty-help - - error-empty-data - - error-invalid-data - - error-open-file - - error-save-file - - export-button - - export-fail-title - - export-success-title - - header - - import-button - - import-fail-title - - import-success-title - - play-selected-tracks-now - - playlist-created - - playlist-exported - - queue - - rename - - songs - - songs_plural - - title - - tracks-selected-plural - - tracks-selected-singular - -### plugins: - - add-a-plugin - - header - - lyrics-providers - - meta-providers - - placeholder - - select-lyrics-provider - - select-meta-provider - - stream-providers - - user-plugins - - user-plugins-warning-desc - - user-plugins-warning-title - -### queue: - - clear - - dialog-accept - - dialog-placeholder - - dialog-trigger - - download - - download-toast-content - - download-toast-title - - favorite-add - - header - - header-track - - id - - loading - - playlist-add - - playlist-toast-content - - playlist-toast-title - - title - -### search: - - album - - album_plural - - artist - - artist_plural - - clear-history - - empty - - last-searches - - placeholder - - playlist - - playlist_plural - - queue-add - - track - - track_plural - - you-can-search-for - -### seekbar: - - segment-popup ### settings: - - api-port - api-url - - autoradio - - autoradio-craziness - - autoradio-craziness-description - - autoradio-description - - compact-menu-bar - - compact-queue-bar - - developer - - devtools - - disable-gpu - - display - - downloads - - downloads-count - - downloads-dir - - downloads-dir-button - - enable-api - - fmfav-btn - - fmfav-msg - - frameless-window - - github-connect - - github-description - github-title - http - - invidious-url - - language - - language-placeholder - - lastfm-connect - - lastfm-description - - lastfm-enable - - lastfm-title - - login - - logout - - loop-after-queue-end - - mastodon-authorization-token-label - - mastodon-authorize - - mastodon-authorized - - mastodon-awaiting-authorization + - lastfm-title - mastodon-description - mastodon-instance-label - - mastodon-post-format-description - mastodon-post-format-label - mastodon-title - - max.downloads - - mini-player - - notification-timeout - - notlogged - - playback - - program-settings - - seek-iteration - - shuffle-queue - - shuffle-when-going-back - - shuffle-when-going-back-description - - social - - streaming - - track-duration - - user - - youtube - - yt-api-key - -### tags: - - albums - - artist - - artists - - duration - - queue-add - - title ### track-popup: - add-to-favorite @@ -3036,9 +2636,6 @@ - tracks-selected-label-plural - tracks-selected-label-singular -### visualizer: - - exit-fullscreen - ## pa_IN ### album: @@ -3837,8 +3434,6 @@ ## ru ### album: - - download - - download-toast-content - download-toast-title - error-load - genre @@ -3881,7 +3476,6 @@ - add-selected-tracks-to-downloads - add-selected-tracks-to-favorites - add-selected-tracks-to-queue - - album - duration - error-empty-data - error-invalid-data @@ -3925,7 +3519,6 @@ - autoradio-description - developer - devtools - - downloads - downloads-count - downloads-dir - downloads-dir-button @@ -3985,7 +3578,6 @@ - error-load - genre - play - - tracks - year ### app: @@ -4680,7 +4272,6 @@ ### plugins: - add-a-plugin - - header - lyrics-providers - meta-providers - select-lyrics-provider @@ -4709,7 +4300,6 @@ - developer - devtools - display - - downloads - downloads-count - downloads-dir - fmfav-btn @@ -4990,6 +4580,227 @@ - tracks-selected-label-plural - tracks-selected-label-singular +## yue_CN + +### artist: + - tour + +### dashboard: + - add-all + +### favorite-artists: + - empty-help + - header + +### favorites: + - artist + - empty + - empty-help + - header + - title + +### help: + - about + - header + - released + - report + - thanks + +### input-dialog: + - cancel + +### library: + - add + - album + - artist + - empty + - empty-help + - filter-placeholder + - header + - no-search-results + - no-search-results-help + - title + +### lyrics: + - by-artist + - empty + - empty-help + - not-found + +### option-control: + - autoradio + - loop + - mini-player + - shuffle + +### player: + - next-button + - play-pause-button + - previous-button + +### playlists: + - add-selected-tracks-to-downloads + - add-selected-tracks-to-favorites + - add-selected-tracks-to-queue + - album + - artist + - delete + - dialog-placeholder + - duration + - empty + - empty-help + - error-empty-data + - error-invalid-data + - error-open-file + - error-save-file + - export-button + - import-fail-title + - import-success-title + - play-selected-tracks-now + - playlist-created + - playlist-exported + - queue + - rename + - title + - tracks-selected-plural + - tracks-selected-singular + +### plugins: + - add-a-plugin + - header + - lyrics-providers + - meta-providers + - placeholder + - select-lyrics-provider + - select-meta-provider + - stream-providers + - user-plugins + - user-plugins-warning-desc + - user-plugins-warning-title + +### queue: + - clear + - dialog-accept + - dialog-placeholder + - dialog-trigger + - download + - download-toast-content + - download-toast-title + - favorite-add + - header + - header-track + - id + - loading + - playlist-add + - playlist-toast-content + - playlist-toast-title + - title + +### search: + - clear-history + - empty + - last-searches + - placeholder + - queue-add + - you-can-search-for + +### seekbar: + - segment-popup + +### settings: + - api-port + - api-url + - autoradio + - autoradio-craziness + - autoradio-craziness-description + - autoradio-description + - compact-menu-bar + - compact-queue-bar + - developer + - devtools + - disable-gpu + - display + - downloads + - downloads-count + - downloads-dir + - downloads-dir-button + - enable-api + - fmfav-btn + - fmfav-msg + - frameless-window + - github-connect + - github-description + - github-title + - http + - invidious-url + - language + - language-placeholder + - lastfm-connect + - lastfm-description + - lastfm-enable + - lastfm-title + - login + - logout + - loop-after-queue-end + - mastodon-authorization-token-label + - mastodon-authorize + - mastodon-authorized + - mastodon-awaiting-authorization + - mastodon-description + - mastodon-instance-label + - mastodon-post-format-description + - mastodon-post-format-label + - mastodon-title + - max.downloads + - mini-player + - notification-timeout + - notlogged + - playback + - program-settings + - seek-iteration + - shuffle-queue + - shuffle-when-going-back + - shuffle-when-going-back-description + - social + - streaming + - track-duration + - user + - youtube + - yt-api-key + +### tags: + - albums + - artist + - artists + - duration + - queue-add + - title + +### track-popup: + - add-to-favorite + - add-to-playlist + - add-to-queue + - download + - download-toast-body + - download-toast-title + - favorite-toast-body + - favorite-toast-title + - play-next + - play-now + - playlist-toast-body + - playlist-toast-title + +### track-table: + - add-selected-tracks-to-downloads + - add-selected-tracks-to-favorites + - add-selected-tracks-to-queue + - play-selected-tracks-now + - tracks-selected-label-plural + - tracks-selected-label-singular + +### visualizer: + - exit-fullscreen + ## yue_HK ### album: diff --git a/packages/app/app/actions/actionTypes.ts b/packages/app/app/actions/actionTypes.ts index a4d94a6233..e2b12538b3 100644 --- a/packages/app/app/actions/actionTypes.ts +++ b/packages/app/app/actions/actionTypes.ts @@ -75,3 +75,22 @@ export enum Mastodon { MASTODON_LOG_OUT = 'MASTODON_LOG_OUT' } + +export enum Connectivity { + CHANGE_CONNECTIVITY = 'CHANGE_CONNECTIVITY' +} + +export enum Dashboard { + LOAD_BEST_NEW_ALBUMS_START = 'LOAD_BEST_NEW_ALBUMS_START', + LOAD_BEST_NEW_ALBUMS_SUCCESS = 'LOAD_BEST_NEW_ALBUMS_SUCCESS', + LOAD_BEST_NEW_ALBUMS_ERROR = 'LOAD_BEST_NEW_ALBUMS_ERROR', + LOAD_BEST_NEW_TRACKS_START = 'LOAD_BEST_NEW_TRACKS_START', + LOAD_BEST_NEW_TRACKS_SUCCESS = 'LOAD_BEST_NEW_TRACKS_SUCCESS', + LOAD_BEST_NEW_TRACKS_ERROR = 'LOAD_BEST_NEW_TRACKS_ERROR', + LOAD_TOP_TAGS_START = 'LOAD_TOP_TAGS_START', + LOAD_TOP_TAGS_SUCCESS = 'LOAD_TOP_TAGS_SUCCESS', + LOAD_TOP_TAGS_ERROR = 'LOAD_TOP_TAGS_ERROR', + LOAD_TOP_TRACKS_START = 'LOAD_TOP_TRACKS_START', + LOAD_TOP_TRACKS_SUCCESS = 'LOAD_TOP_TRACKS_SUCCESS', + LOAD_TOP_TRACKS_ERROR = 'LOAD_TOP_TRACKS_ERROR', +} diff --git a/packages/app/app/actions/connectivity.js b/packages/app/app/actions/connectivity.js deleted file mode 100644 index 29c40b4d41..0000000000 --- a/packages/app/app/actions/connectivity.js +++ /dev/null @@ -1,6 +0,0 @@ -export const CHANGE_CONNECTIVITY = 'CHANGE_CONNECTIVITY'; - -export const changeConnectivity = (payload) => ({ - type: CHANGE_CONNECTIVITY, - payload -}); diff --git a/packages/app/app/actions/connectivity.ts b/packages/app/app/actions/connectivity.ts new file mode 100644 index 0000000000..0a232b4094 --- /dev/null +++ b/packages/app/app/actions/connectivity.ts @@ -0,0 +1,4 @@ +import { createStandardAction } from 'typesafe-actions'; +import { Connectivity } from './actionTypes'; + +export const changeConnectivity = createStandardAction(Connectivity.CHANGE_CONNECTIVITY)(); diff --git a/packages/app/app/actions/dashboard.js b/packages/app/app/actions/dashboard.js deleted file mode 100644 index 5bb8cc91df..0000000000 --- a/packages/app/app/actions/dashboard.js +++ /dev/null @@ -1,159 +0,0 @@ -import logger from 'electron-timber'; -import { rest } from '@nuclear/core'; -import { getBestNewAlbums, getBestNewTracks } from 'pitchfork-bnm'; - -import globals from '../globals'; -import { Deezer } from '@nuclear/core/src/rest'; - -const lastfm = new rest.LastFmApi( - globals.lastfmApiKey, - globals.lastfmApiSecret -); - -export const LOAD_BEST_NEW_ALBUMS_START = 'LOAD_BEST_NEW_ALBUMS_START'; -export const LOAD_BEST_NEW_ALBUMS_SUCCESS = 'LOAD_BEST_NEW_ALBUMS_SUCCESS'; -export const LOAD_BEST_NEW_ALBUMS_ERROR = 'LOAD_BEST_NEW_ALBUMS_ERROR'; - -export const LOAD_BEST_NEW_TRACKS_START = 'LOAD_BEST_NEW_TRACKS_START'; -export const LOAD_BEST_NEW_TRACKS_SUCCESS = 'LOAD_BEST_NEW_TRACKS_SUCCESS'; -export const LOAD_BEST_NEW_TRACKS_ERROR = 'LOAD_BEST_NEW_TRACKS_ERROR'; - -export const LOAD_TOP_TAGS_START = 'LOAD_TOP_TAGS_START'; -export const LOAD_TOP_TAGS_SUCCESS = 'LOAD_TOP_TAGS_SUCCESS'; -export const LOAD_TOP_TAGS_ERROR = 'LOAD_TOP_TAGS_ERROR'; - -export const LOAD_TOP_TRACKS_START = 'LOAD_TOP_TRACKS_START'; -export const LOAD_TOP_TRACKS_SUCCESS = 'LOAD_TOP_TRACKS_SUCCESS'; -export const LOAD_TOP_TRACKS_ERROR = 'LOAD_TOP_TRACKS_ERROR'; - -export function loadTopTagsStart() { - return { - type: LOAD_TOP_TAGS_START - }; -} - -export function loadTopTagsSuccess(tags) { - return { - type: LOAD_TOP_TAGS_SUCCESS, - payload: tags - }; -} - -export function loadTopTagsError() { - return { - type: LOAD_TOP_TAGS_ERROR - }; -} - -export function loadTopTags() { - return dispatch => { - dispatch(loadTopTagsStart()); - lastfm - .getTopTags() - .then(response => response.json()) - .then(results => { - dispatch(loadTopTagsSuccess(results.toptags.tag)); - }) - .catch(error => { - dispatch(loadTopTagsError()); - logger.error(error); - }); - }; -} - -export function loadBestNewAlbumsStart() { - return { - type: LOAD_BEST_NEW_ALBUMS_START - }; -} - -export function loadBestNewAlbumsSuccess(albums) { - return { - type: LOAD_BEST_NEW_ALBUMS_SUCCESS, - payload: albums - }; -} - -export function loadBestNewAlbumsError() { - return { - type: LOAD_BEST_NEW_ALBUMS_ERROR - }; -} - -export function loadBestNewAlbums() { - return dispatch => { - dispatch(loadBestNewAlbumsStart()); - getBestNewAlbums() - .then(albums => { - dispatch(loadBestNewAlbumsSuccess(albums)); - }) - .catch(error => { - dispatch(loadBestNewAlbumsError()); - logger.error(error); - }); - }; -} - -export function loadBestNewTracksStart() { - return { - type: LOAD_BEST_NEW_TRACKS_START - }; -} - -export function loadBestNewTracksSuccess(tracks) { - return { - type: LOAD_BEST_NEW_TRACKS_SUCCESS, - payload: tracks - }; -} - -export function loadBestNewTracksError() { - return { - type: LOAD_BEST_NEW_TRACKS_ERROR - }; -} - -export function loadBestNewTracks() { - return dispatch => { - dispatch(loadBestNewAlbumsStart()); - getBestNewTracks() - .then(tracks => { - dispatch(loadBestNewTracksSuccess(tracks)); - }) - .catch(error => { - dispatch(loadBestNewTracksError()); - logger.error(error); - }); - }; -} - -export function loadTopTracksStart() { - return { - type: LOAD_TOP_TRACKS_START - }; -} - -export function loadTopTracksSuccess(tracks) { - return { - type: LOAD_TOP_TRACKS_SUCCESS, - payload: tracks - }; -} - -export function loadTopTracksError() { - return { - type: LOAD_TOP_TRACKS_ERROR - }; -} - -export const loadTopTracks = () => async (dispatch) => { - dispatch(loadTopTracksStart()); - - try { - const tracks = await Deezer.getTopTracks(); - dispatch(loadTopTracksSuccess(tracks.data.map(Deezer.mapDeezerTrackToInternal))); - } catch (error) { - dispatch(loadTopTracksError()); - logger.error(error); - } -}; diff --git a/packages/app/app/actions/dashboard.ts b/packages/app/app/actions/dashboard.ts new file mode 100644 index 0000000000..a90c4dbe69 --- /dev/null +++ b/packages/app/app/actions/dashboard.ts @@ -0,0 +1,93 @@ +import logger from 'electron-timber'; +import { rest } from '@nuclear/core'; +import { getBestNewAlbums, getBestNewTracks } from 'pitchfork-bnm'; +import { Deezer } from '@nuclear/core/src/rest'; + +import globals from '../globals'; +import { Dashboard } from './actionTypes'; +import { createAsyncAction } from 'typesafe-actions'; + +const lastfm = new rest.LastFmApi( + globals.lastfmApiKey, + globals.lastfmApiSecret +); + +export const loadTopTagsAction = createAsyncAction( + Dashboard.LOAD_TOP_TAGS_START, + Dashboard.LOAD_TOP_TAGS_SUCCESS, + Dashboard.LOAD_TOP_TAGS_ERROR +)(); + +export function loadTopTags() { + return dispatch => { + dispatch(loadTopTagsAction.request()); + lastfm + .getTopTags() + .then(response => response.json()) + .then(results => { + dispatch(loadTopTagsAction.success(results.toptags.tag)); + }) + .catch(error => { + dispatch(loadTopTagsAction.failure()); + logger.error(error); + }); + }; +} + +export const loadBestNewAlbumsAction = createAsyncAction( + Dashboard.LOAD_BEST_NEW_ALBUMS_START, + Dashboard.LOAD_BEST_NEW_ALBUMS_SUCCESS, + Dashboard.LOAD_BEST_NEW_ALBUMS_ERROR +)(); + +export function loadBestNewAlbums() { + return dispatch => { + dispatch(loadBestNewAlbumsAction.request()); + getBestNewAlbums() + .then(albums => { + dispatch(loadBestNewAlbumsAction.success(albums)); + }) + .catch(error => { + dispatch(loadBestNewAlbumsAction.failure()); + logger.error(error); + }); + }; +} + +export const loadBestNewTracksAction = createAsyncAction( + Dashboard.LOAD_BEST_NEW_TRACKS_START, + Dashboard.LOAD_BEST_NEW_TRACKS_SUCCESS, + Dashboard.LOAD_BEST_NEW_TRACKS_ERROR +)(); + +export function loadBestNewTracks() { + return dispatch => { + dispatch(loadBestNewTracksAction.request()); + getBestNewTracks() + .then(tracks => { + dispatch(loadBestNewTracksAction.success(tracks)); + }) + .catch(error => { + dispatch(loadBestNewTracksAction.failure()); + logger.error(error); + }); + }; +} + +export const loadTopTracksAction = createAsyncAction( + Dashboard.LOAD_TOP_TRACKS_START, + Dashboard.LOAD_TOP_TRACKS_SUCCESS, + Dashboard.LOAD_TOP_TRACKS_ERROR +)(); + +export const loadTopTracks = () => async (dispatch) => { + dispatch(loadTopTracksAction.request()); + + try { + const tracks = await Deezer.getTopTracks(); + dispatch(loadTopTracksAction.success(tracks.data.map(Deezer.mapDeezerTrackToInternal))); + } catch (error) { + dispatch(loadTopTracksAction.failure()); + logger.error(error); + } +}; diff --git a/packages/app/app/reducers/connectivity.js b/packages/app/app/reducers/connectivity.ts similarity index 57% rename from packages/app/app/reducers/connectivity.js rename to packages/app/app/reducers/connectivity.ts index 746ab81dd0..a72c9fb431 100644 --- a/packages/app/app/reducers/connectivity.js +++ b/packages/app/app/reducers/connectivity.ts @@ -1,8 +1,9 @@ -import { CHANGE_CONNECTIVITY } from '../actions/connectivity'; +import { getType } from 'typesafe-actions'; +import { changeConnectivity } from '../actions/connectivity'; function ConnectivityReducer(state = navigator.onLine, action) { switch (action.type) { - case CHANGE_CONNECTIVITY: + case getType(changeConnectivity): return action.payload; default: return state; diff --git a/packages/app/app/reducers/dashboard.js b/packages/app/app/reducers/dashboard.ts similarity index 60% rename from packages/app/app/reducers/dashboard.js rename to packages/app/app/reducers/dashboard.ts index 40262a3705..97fb9de7a6 100644 --- a/packages/app/app/reducers/dashboard.js +++ b/packages/app/app/reducers/dashboard.ts @@ -1,9 +1,5 @@ -import { - LOAD_BEST_NEW_ALBUMS_SUCCESS, - LOAD_BEST_NEW_TRACKS_SUCCESS, - LOAD_TOP_TAGS_SUCCESS, - LOAD_TOP_TRACKS_SUCCESS -} from '../actions/dashboard'; +import { getType } from 'typesafe-actions'; +import {loadBestNewAlbumsAction, loadBestNewTracksAction, loadTopTagsAction, loadTopTracksAction} from '../actions/dashboard'; const initialState = { bestNewAlbums: [], @@ -13,19 +9,19 @@ const initialState = { export default function DashboardReducer(state = initialState, action) { switch (action.type) { - case LOAD_BEST_NEW_ALBUMS_SUCCESS: + case getType(loadBestNewAlbumsAction.success): return Object.assign({}, state, { bestNewAlbums: action.payload }); - case LOAD_BEST_NEW_TRACKS_SUCCESS: + case getType(loadBestNewTracksAction.success): return Object.assign({}, state, { bestNewTracks: action.payload }); - case LOAD_TOP_TAGS_SUCCESS: + case getType(loadTopTagsAction.success): return Object.assign({}, state, { topTags: action.payload }); - case LOAD_TOP_TRACKS_SUCCESS: + case getType(loadTopTracksAction.success): return Object.assign({}, state, { topTracks: action.payload }); diff --git a/packages/app/app/store/middlewares/ipc.js b/packages/app/app/store/middlewares/ipc.ts similarity index 90% rename from packages/app/app/store/middlewares/ipc.js rename to packages/app/app/store/middlewares/ipc.ts index a6b8d39ac1..56a8ff60fa 100644 --- a/packages/app/app/store/middlewares/ipc.js +++ b/packages/app/app/store/middlewares/ipc.ts @@ -5,10 +5,19 @@ import _ from 'lodash'; import { PAUSE_PLAYBACK, START_PLAYBACK, UPDATE_VOLUME } from '../../actions/player'; import { LocalLibrary } from '../../actions/actionTypes'; import { ADD_QUEUE_ITEM, CLEAR_QUEUE, REMOVE_QUEUE_ITEM, QUEUE_DROP } from '../../actions/queue'; -import { SET_BOOLEAN_OPTION, SET_NUMBER_OPTION } from '../../actions/settings'; -import { CHANGE_CONNECTIVITY } from '../../actions/connectivity'; +import { Settings } from '../../actions/actionTypes'; +import { changeConnectivity } from '../../actions/connectivity'; import { ADD_TO_DOWNLOADS, DOWNLOAD_RESUMED, DOWNLOAD_PAUSED, DOWNLOAD_FINISHED, DOWNLOAD_ERROR } from '../../actions/downloads'; import { CLOSE_WINDOW, MINIMIZE_WINDOW, MAXIMIZE_WINDOW, OPEN_DEVTOOLS } from '../../actions/window'; +import { getType } from 'typesafe-actions'; + +type IpcActionType = { + type: string; + payload: any; + meta: { + fromMain?: boolean; + }; +} const ipcConnect = () => next => { next({ @@ -21,7 +30,7 @@ const ipcConnect = () => next => { payload: ipcRenderer.sendSync(IpcEvents.LOCAL_METAS) }); - return ({ meta = {}, payload, type }) => { + return ({ meta = {}, payload, type }: IpcActionType) => { if (meta.fromMain) { next({ type, payload }); return; @@ -60,7 +69,7 @@ const ipcConnect = () => next => { case QUEUE_DROP: return ipcRenderer.send(IpcEvents.QUEUE_DROP, payload); - case SET_BOOLEAN_OPTION: + case Settings.SET_BOOLEAN_OPTION: switch (payload.option) { case 'api.enabled': ipcRenderer.send(payload.state ? IpcEvents.API_RESTART : IpcEvents.API_STOP); @@ -73,13 +82,13 @@ const ipcConnect = () => next => { break; } break; - case SET_NUMBER_OPTION: + case Settings.SET_NUMBER_OPTION: if (payload.option === 'api.port' && isValidPort(payload.state) && getOption('api.enabled')) { ipcRenderer.send(IpcEvents.API_RESTART); } break; - case CHANGE_CONNECTIVITY: + case getType(changeConnectivity): ipcRenderer.send(IpcEvents.CONNECTIVITY, payload); break;