From fec24c8a81a90cf713cefc88288c30556d243d4f Mon Sep 17 00:00:00 2001 From: Nick Barrett Date: Sat, 31 Jul 2021 11:53:23 +0100 Subject: [PATCH] Handle update errors in the UI. --- kanmail/client/components/emails/Filters.jsx | 11 +++++++++++ kanmail/client/stores/update.js | 5 +++++ kanmail/client/styles/themes/base.less | 4 ++++ 3 files changed, 20 insertions(+) diff --git a/kanmail/client/components/emails/Filters.jsx b/kanmail/client/components/emails/Filters.jsx index 6c80bca7..c2d99927 100644 --- a/kanmail/client/components/emails/Filters.jsx +++ b/kanmail/client/components/emails/Filters.jsx @@ -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) { @@ -241,6 +242,16 @@ export default class Filters extends React.Component { } renderUpdateLink() { + if (this.props.updateError) { + return ( +
  • openLink('https://kanmail.io/download')}> + + Error downloading update: {this.props.updateError}.
    Please re-download the latest version from the Kanmail website. +
    +
  • + ); + } + if (!this.props.updateVersion) { return; } diff --git a/kanmail/client/stores/update.js b/kanmail/client/stores/update.js index d66b8108..89127bd2 100644 --- a/kanmail/client/stores/update.js +++ b/kanmail/client/stores/update.js @@ -17,6 +17,7 @@ class UpdateStore extends BaseStore { updateVersion: null, updateReady: false, updateDownloading: false, + updateError: null, }; } @@ -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(); }); } } diff --git a/kanmail/client/styles/themes/base.less b/kanmail/client/styles/themes/base.less index a708a71f..63c9d0a0 100644 --- a/kanmail/client/styles/themes/base.less +++ b/kanmail/client/styles/themes/base.less @@ -205,6 +205,10 @@ section#sidebar { span.update { background: @green; color: white; + + &.error { + background: @red; + } } a {