Skip to content

Commit

Permalink
Handle update errors in the UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fizzadar committed Jul 31, 2021
1 parent f882d40 commit fec24c8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions kanmail/client/components/emails/Filters.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export default class Filters extends React.Component {
folders: PropTypes.array.isRequired,
accountName: PropTypes.string,
updateVersion: PropTypes.string,
updateError: PropTypes.string,
}

constructor(props) {
Expand Down Expand Up @@ -241,6 +242,16 @@ export default class Filters extends React.Component {
}

renderUpdateLink() {
if (this.props.updateError) {
return (
<li><a onClick={() => openLink('https://kanmail.io/download')}>
<span className="update error">
Error downloading update: <code>{this.props.updateError}</code>.<br />Please re-download the latest version from the Kanmail website.
</span>
</a></li>
);
}

if (!this.props.updateVersion) {
return;
}
Expand Down
5 changes: 5 additions & 0 deletions kanmail/client/stores/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class UpdateStore extends BaseStore {
updateVersion: null,
updateReady: false,
updateDownloading: false,
updateError: null,
};
}

Expand All @@ -37,6 +38,10 @@ class UpdateStore extends BaseStore {
return post('/api/update').then(() => {
this.props.updateReady = true;
this.triggerUpdate();
}).catch((e) => {
this.props.updateDownloading = false;
this.props.updateError = e.data ? e.data.errorMessage : 'unknown';
this.triggerUpdate();
});
}
}
Expand Down
4 changes: 4 additions & 0 deletions kanmail/client/styles/themes/base.less
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ section#sidebar {
span.update {
background: @green;
color: white;

&.error {
background: @red;
}
}

a {
Expand Down

0 comments on commit fec24c8

Please sign in to comment.