mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-23 17:47:24 +00:00
148 lines
3.4 KiB
JavaScript
148 lines
3.4 KiB
JavaScript
import * as SETTINGS from 'constants/settings';
|
|
import * as PAGES from 'constants/pages';
|
|
import * as ICONS from 'constants/icons';
|
|
import { createSelector } from 'reselect';
|
|
import { selectCurrentPage, selectHistoryStack } from 'lbry-redux';
|
|
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
|
|
|
export const selectState = state => state.app || {};
|
|
|
|
export const selectPlatform = createSelector(
|
|
selectState,
|
|
state => state.platform
|
|
);
|
|
|
|
export const selectUpdateUrl = createSelector(
|
|
selectPlatform,
|
|
platform => {
|
|
switch (platform) {
|
|
case 'darwin':
|
|
return 'https://lbry.com/get/lbry.dmg';
|
|
case 'linux':
|
|
return 'https://lbry.com/get/lbry.deb';
|
|
case 'win32':
|
|
return 'https://lbry.com/get/lbry.exe';
|
|
default:
|
|
throw Error('Unknown platform');
|
|
}
|
|
}
|
|
);
|
|
|
|
export const selectHasClickedComment = createSelector(
|
|
selectState,
|
|
state => state.hasClickedComment
|
|
);
|
|
|
|
export const selectRemoteVersion = createSelector(
|
|
selectState,
|
|
state => state.remoteVersion
|
|
);
|
|
|
|
export const selectIsUpgradeAvailable = createSelector(
|
|
selectState,
|
|
state => state.isUpgradeAvailable
|
|
);
|
|
|
|
export const selectUpgradeFilename = createSelector(
|
|
selectPlatform,
|
|
selectRemoteVersion,
|
|
(platform, version) => {
|
|
switch (platform) {
|
|
case 'darwin':
|
|
return `LBRY_${version}.dmg`;
|
|
case 'linux':
|
|
return `LBRY_${version}.deb`;
|
|
case 'win32':
|
|
return `LBRY_${version}.exe`;
|
|
default:
|
|
throw Error('Unknown platform');
|
|
}
|
|
}
|
|
);
|
|
|
|
export const selectDownloadProgress = createSelector(
|
|
selectState,
|
|
state => state.downloadProgress
|
|
);
|
|
|
|
export const selectDownloadComplete = createSelector(
|
|
selectState,
|
|
state => state.upgradeDownloadCompleted
|
|
);
|
|
|
|
export const selectIsUpgradeSkipped = createSelector(
|
|
selectState,
|
|
state => state.isUpgradeSkipped
|
|
);
|
|
|
|
export const selectUpgradeDownloadPath = createSelector(
|
|
selectState,
|
|
state => state.downloadPath
|
|
);
|
|
|
|
export const selectUpgradeDownloadItem = createSelector(
|
|
selectState,
|
|
state => state.downloadItem
|
|
);
|
|
|
|
export const selectAutoUpdateDownloaded = createSelector(
|
|
selectState,
|
|
state => state.autoUpdateDownloaded
|
|
);
|
|
|
|
export const selectAutoUpdateDeclined = createSelector(
|
|
selectState,
|
|
state => state.autoUpdateDeclined
|
|
);
|
|
|
|
export const selectDaemonVersionMatched = createSelector(
|
|
selectState,
|
|
state => state.daemonVersionMatched
|
|
);
|
|
|
|
export const selectCurrentLanguage = createSelector(
|
|
selectState,
|
|
() => i18n.getLocale() || 'en'
|
|
);
|
|
|
|
export const selectVolume = createSelector(
|
|
selectState,
|
|
state => state.volume
|
|
);
|
|
|
|
export const selectUpgradeTimer = createSelector(
|
|
selectState,
|
|
state => state.checkUpgradeTimer
|
|
);
|
|
|
|
export const selectModal = createSelector(
|
|
selectState,
|
|
state => {
|
|
if (!state.modal) {
|
|
return null;
|
|
}
|
|
|
|
return {
|
|
id: state.modal,
|
|
modalProps: state.modalProps,
|
|
};
|
|
}
|
|
);
|
|
|
|
export const selectEnhancedLayout = createSelector(
|
|
selectState,
|
|
state => state.enhancedLayout
|
|
);
|
|
|
|
export const selectSearchOptionsExpanded = createSelector(
|
|
selectState,
|
|
state => state.searchOptionsExpanded
|
|
);
|
|
|
|
export const selectShouldShowInviteGuide = createSelector(
|
|
makeSelectClientSetting(SETTINGS.FIRST_RUN_COMPLETED),
|
|
makeSelectClientSetting(SETTINGS.INVITE_ACKNOWLEDGED),
|
|
(firstRunCompleted, inviteAcknowledged) => {
|
|
return firstRunCompleted ? !inviteAcknowledged : false;
|
|
}
|
|
);
|