lbry-desktop/src/renderer/redux/selectors/app.js

81 lines
2.4 KiB
JavaScript
Raw Normal View History

import { createSelector } from 'reselect';
2017-04-07 07:15:22 +02:00
export const selectState = state => state.app || {};
2017-04-07 07:15:22 +02:00
export const selectPlatform = createSelector(selectState, state => state.platform);
2017-06-06 06:21:55 +02:00
export const selectUpdateUrl = createSelector(selectPlatform, platform => {
2017-06-06 23:19:12 +02:00
switch (platform) {
case 'darwin':
return 'https://lbry.io/get/lbry.dmg';
case 'linux':
return 'https://lbry.io/get/lbry.deb';
case 'win32':
return 'https://lbry.io/get/lbry.exe';
2017-06-06 23:19:12 +02:00
default:
throw Error('Unknown platform');
2017-04-07 07:15:22 +02:00
}
2017-06-06 06:21:55 +02:00
});
2017-04-07 07:15:22 +02:00
export const selectRemoteVersion = createSelector(selectState, state => state.remoteVersion);
export const selectIsUpgradeAvailable = createSelector(
selectState,
state => state.isUpgradeAvailable
);
2017-04-07 07:15:22 +02:00
export const selectUpgradeFilename = createSelector(
selectPlatform,
selectRemoteVersion,
2017-04-07 07:15:22 +02:00
(platform, version) => {
switch (platform) {
case 'darwin':
return `LBRY_${version}.dmg`;
case 'linux':
2017-04-07 07:15:22 +02:00
return `LBRY_${version}_amd64.deb`;
case 'win32':
return `LBRY_${version}.exe`;
2017-04-07 07:15:22 +02:00
default:
throw Error('Unknown platform');
2017-04-07 07:15:22 +02:00
}
}
2017-06-06 06:21:55 +02:00
);
2017-04-07 07:15:22 +02:00
export const selectCurrentModal = createSelector(selectState, state => state.modal);
2017-04-07 07:15:22 +02:00
export const selectDownloadProgress = createSelector(selectState, state => state.downloadProgress);
2017-04-07 07:15:22 +02:00
export const selectDownloadComplete = createSelector(
selectState,
2017-06-06 23:19:12 +02:00
state => state.upgradeDownloadCompleted
2017-06-06 06:21:55 +02:00
);
export const selectIsUpgradeSkipped = createSelector(selectState, state => state.isUpgradeSkipped);
2017-04-07 07:15:22 +02:00
export const selectUpgradeDownloadPath = createSelector(selectState, state => state.downloadPath);
2017-04-07 07:15:22 +02:00
export const selectUpgradeDownloadItem = createSelector(selectState, state => state.downloadItem);
2017-04-07 07:15:22 +02:00
export const selectModalProps = createSelector(selectState, state => state.modalProps);
2017-04-22 15:17:01 +02:00
export const selectDaemonVersionMatched = createSelector(
selectState,
state => state.daemonVersionMatched
);
export const selectSnackBar = createSelector(selectState, state => state.snackBar || {});
2017-05-23 09:21:21 +02:00
export const selectSnackBarSnacks = createSelector(
selectSnackBar,
2017-06-06 23:19:12 +02:00
snackBar => snackBar.snacks || []
2017-06-06 06:21:55 +02:00
);
export const selectBadgeNumber = createSelector(selectState, state => state.badgeNumber);
2017-07-07 15:15:45 +02:00
export const selectCurrentLanguage = createSelector(
selectState,
() => app.i18n.getLocale() || 'en'
2017-08-08 11:36:14 +02:00
);
export const selectVolume = createSelector(selectState, state => state.volume);