Fixed: Fetch Settings in UpdateConnector

pull/1689/head
Qstick 4 years ago
parent 3f3dd20371
commit 852d284670

@ -1,8 +1,4 @@
.updateAvailable { .messageContainer {
display: flex;
}
.upToDate {
display: flex; display: flex;
margin-bottom: 20px; margin-bottom: 20px;
} }
@ -12,7 +8,7 @@
font-size: 30px; font-size: 30px;
} }
.upToDateMessage { .message {
padding-left: 5px; padding-left: 5px;
font-size: 18px; font-size: 18px;
line-height: 30px; line-height: 30px;

@ -23,7 +23,8 @@ class Updates extends Component {
currentVersion, currentVersion,
isFetching, isFetching,
isPopulated, isPopulated,
error, updatesError,
generalSettingsError,
items, items,
isInstallingUpdate, isInstallingUpdate,
updateMechanism, updateMechanism,
@ -33,8 +34,9 @@ class Updates extends Component {
onInstallLatestPress onInstallLatestPress
} = this.props; } = this.props;
const hasUpdates = isPopulated && !error && items.length > 0; const hasError = !!(updatesError || generalSettingsError);
const noUpdates = isPopulated && !error && !items.length; const hasUpdates = isPopulated && !hasError && items.length > 0;
const noUpdates = isPopulated && !hasError && !items.length;
const hasUpdateToInstall = hasUpdates && _.some(items, { installable: true, latest: true }); const hasUpdateToInstall = hasUpdates && _.some(items, { installable: true, latest: true });
const noUpdateToInstall = hasUpdates && !hasUpdateToInstall; const noUpdateToInstall = hasUpdates && !hasUpdateToInstall;
@ -49,7 +51,7 @@ class Updates extends Component {
<PageContent title="Updates"> <PageContent title="Updates">
<PageContentBodyConnector> <PageContentBodyConnector>
{ {
!isPopulated && !error && !isPopulated && !hasError &&
<LoadingIndicator /> <LoadingIndicator />
} }
@ -97,13 +99,13 @@ class Updates extends Component {
{ {
noUpdateToInstall && noUpdateToInstall &&
<div className={styles.upToDate}> <div className={styles.messageContainer}>
<Icon <Icon
className={styles.upToDateIcon} className={styles.upToDateIcon}
name={icons.CHECK_CIRCLE} name={icons.CHECK_CIRCLE}
size={30} size={30}
/> />
<div className={styles.upToDateMessage}> <div className={styles.message}>
The latest version of Lidarr is already installed The latest version of Lidarr is already installed
</div> </div>
@ -183,11 +185,18 @@ class Updates extends Component {
} }
{ {
!!error && !!updatesError &&
<div> <div>
Failed to fetch updates Failed to fetch updates
</div> </div>
} }
{
!!generalSettingsError &&
<div>
Failed to update settings
</div>
}
</PageContentBodyConnector> </PageContentBodyConnector>
</PageContent> </PageContent>
); );
@ -199,7 +208,8 @@ Updates.propTypes = {
currentVersion: PropTypes.string.isRequired, currentVersion: PropTypes.string.isRequired,
isFetching: PropTypes.bool.isRequired, isFetching: PropTypes.bool.isRequired,
isPopulated: PropTypes.bool.isRequired, isPopulated: PropTypes.bool.isRequired,
error: PropTypes.object, updatesError: PropTypes.object,
generalSettingsError: PropTypes.object,
items: PropTypes.array.isRequired, items: PropTypes.array.isRequired,
isInstallingUpdate: PropTypes.bool.isRequired, isInstallingUpdate: PropTypes.bool.isRequired,
isDocker: PropTypes.bool.isRequired, isDocker: PropTypes.bool.isRequired,

@ -2,6 +2,7 @@ import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { fetchGeneralSettings } from 'Store/Actions/settingsActions';
import { fetchUpdates } from 'Store/Actions/systemActions'; import { fetchUpdates } from 'Store/Actions/systemActions';
import { executeCommand } from 'Store/Actions/commandActions'; import { executeCommand } from 'Store/Actions/commandActions';
import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector'; import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector';
@ -17,29 +18,31 @@ function createMapStateToProps() {
(state) => state.system.updates, (state) => state.system.updates,
(state) => state.settings.general, (state) => state.settings.general,
createUISettingsSelector(), createUISettingsSelector(),
createCommandExecutingSelector(commandNames.APPLICATION_UPDATE),
createSystemStatusSelector(), createSystemStatusSelector(),
createCommandExecutingSelector(commandNames.APPLICATION_UPDATE),
( (
currentVersion, currentVersion,
status, status,
updates, updates,
generalSettings, generalSettings,
uiSettings, uiSettings,
isInstallingUpdate, systemStatus,
systemStatus isInstallingUpdate
) => { ) => {
const { const {
isFetching, error: updatesError,
isPopulated,
error,
items items
} = updates; } = updates;
const isFetching = updates.isFetching || generalSettings.isFetching;
const isPopulated = updates.isPopulated && generalSettings.isPopulated;
return { return {
currentVersion, currentVersion,
isFetching, isFetching,
isPopulated, isPopulated,
error, updatesError,
generalSettingsError: generalSettings.error,
items, items,
isInstallingUpdate, isInstallingUpdate,
isDocker: systemStatus.isDocker, isDocker: systemStatus.isDocker,
@ -52,8 +55,9 @@ function createMapStateToProps() {
} }
const mapDispatchToProps = { const mapDispatchToProps = {
fetchUpdates, dispatchFetchUpdates: fetchUpdates,
executeCommand dispatchFetchGeneralSettings: fetchGeneralSettings,
dispatchExecuteCommand: executeCommand
}; };
class UpdatesConnector extends Component { class UpdatesConnector extends Component {
@ -62,14 +66,15 @@ class UpdatesConnector extends Component {
// Lifecycle // Lifecycle
componentDidMount() { componentDidMount() {
this.props.fetchUpdates(); this.props.dispatchFetchUpdates();
this.props.dispatchFetchGeneralSettings();
} }
// //
// Listeners // Listeners
onInstallLatestPress = () => { onInstallLatestPress = () => {
this.props.executeCommand({ name: commandNames.APPLICATION_UPDATE }); this.props.dispatchExecuteCommand({ name: commandNames.APPLICATION_UPDATE });
} }
// //
@ -86,8 +91,9 @@ class UpdatesConnector extends Component {
} }
UpdatesConnector.propTypes = { UpdatesConnector.propTypes = {
fetchUpdates: PropTypes.func.isRequired, dispatchFetchUpdates: PropTypes.func.isRequired,
executeCommand: PropTypes.func.isRequired dispatchFetchGeneralSettings: PropTypes.func.isRequired,
dispatchExecuteCommand: PropTypes.func.isRequired
}; };
export default connect(createMapStateToProps, mapDispatchToProps)(UpdatesConnector); export default connect(createMapStateToProps, mapDispatchToProps)(UpdatesConnector);

Loading…
Cancel
Save