2017-12-21 18:32:51 +01:00
|
|
|
import { createSelector } from 'reselect';
|
2017-04-07 07:15:22 +02:00
|
|
|
|
2017-12-21 18:32:51 +01:00
|
|
|
export const selectState = state => state.app || {};
|
2017-04-07 07:15:22 +02:00
|
|
|
|
2017-12-21 18:32:51 +01: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) {
|
2017-12-21 18:32:51 +01:00
|
|
|
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:
|
2017-12-21 18:32:51 +01:00
|
|
|
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
|
|
|
|
2017-12-21 18:32:51 +01:00
|
|
|
export const selectRemoteVersion = createSelector(selectState, state => state.remoteVersion);
|
2017-11-15 02:50:21 +01:00
|
|
|
|
|
|
|
export const selectIsUpgradeAvailable = createSelector(
|
2017-12-21 18:32:51 +01:00
|
|
|
selectState,
|
2017-11-15 02:50:21 +01:00
|
|
|
state => state.isUpgradeAvailable
|
|
|
|
);
|
2017-04-07 07:15:22 +02:00
|
|
|
|
|
|
|
export const selectUpgradeFilename = createSelector(
|
|
|
|
selectPlatform,
|
2017-11-15 02:50:21 +01:00
|
|
|
selectRemoteVersion,
|
2017-04-07 07:15:22 +02:00
|
|
|
(platform, version) => {
|
|
|
|
switch (platform) {
|
2017-12-21 18:32:51 +01:00
|
|
|
case 'darwin':
|
2017-06-01 08:52:17 +02:00
|
|
|
return `LBRY_${version}.dmg`;
|
2017-12-21 18:32:51 +01:00
|
|
|
case 'linux':
|
2017-04-07 07:15:22 +02:00
|
|
|
return `LBRY_${version}_amd64.deb`;
|
2017-12-21 18:32:51 +01:00
|
|
|
case 'win32':
|
2017-06-01 08:52:17 +02:00
|
|
|
return `LBRY_${version}.exe`;
|
2017-04-07 07:15:22 +02:00
|
|
|
default:
|
2017-12-21 18:32:51 +01:00
|
|
|
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
|
|
|
|
2017-12-21 18:32:51 +01:00
|
|
|
export const selectCurrentModal = createSelector(selectState, state => state.modal);
|
2017-04-07 07:15:22 +02:00
|
|
|
|
2017-12-21 18:32:51 +01:00
|
|
|
export const selectDownloadProgress = createSelector(selectState, state => state.downloadProgress);
|
2017-04-07 07:15:22 +02:00
|
|
|
|
|
|
|
export const selectDownloadComplete = createSelector(
|
2017-12-21 18:32:51 +01:00
|
|
|
selectState,
|
2017-06-06 23:19:12 +02:00
|
|
|
state => state.upgradeDownloadCompleted
|
2017-06-06 06:21:55 +02:00
|
|
|
);
|
|
|
|
|
2017-12-21 18:32:51 +01:00
|
|
|
export const selectIsUpgradeSkipped = createSelector(selectState, state => state.isUpgradeSkipped);
|
2017-04-07 07:15:22 +02:00
|
|
|
|
2017-12-21 18:32:51 +01:00
|
|
|
export const selectUpgradeDownloadPath = createSelector(selectState, state => state.downloadPath);
|
2017-04-07 07:15:22 +02:00
|
|
|
|
2017-12-21 18:32:51 +01:00
|
|
|
export const selectUpgradeDownloadItem = createSelector(selectState, state => state.downloadItem);
|
2017-04-07 07:15:22 +02:00
|
|
|
|
2017-12-21 18:32:51 +01:00
|
|
|
export const selectModalProps = createSelector(selectState, state => state.modalProps);
|
2017-04-22 15:17:01 +02:00
|
|
|
|
2017-07-19 23:05:08 +02:00
|
|
|
export const selectDaemonVersionMatched = createSelector(
|
2017-12-21 18:32:51 +01:00
|
|
|
selectState,
|
2017-07-19 23:05:08 +02:00
|
|
|
state => state.daemonVersionMatched
|
|
|
|
);
|
|
|
|
|
2017-12-21 18:32:51 +01:00
|
|
|
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
|
|
|
);
|
2017-06-24 10:57:37 +02:00
|
|
|
|
2017-12-21 18:32:51 +01:00
|
|
|
export const selectBadgeNumber = createSelector(selectState, state => state.badgeNumber);
|
2017-07-07 15:15:45 +02:00
|
|
|
|
|
|
|
export const selectCurrentLanguage = createSelector(
|
2017-12-21 18:32:51 +01:00
|
|
|
selectState,
|
|
|
|
() => app.i18n.getLocale() || 'en'
|
2017-08-08 11:36:14 +02:00
|
|
|
);
|
|
|
|
|
2017-12-21 18:32:51 +01:00
|
|
|
export const selectVolume = createSelector(selectState, state => state.volume);
|