1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-11-24 08:12:24 +02:00

Desktop: Resolves #2688: Add "Retry All" option to synchronisation page

Based on pull request #2712 by fhfuih

commit 7d3815e51dbf682ecc1ed3544a15e51b79d5d12d
Author: Laurent Cozic <laurent@cozic.net>
Date:   Sat Apr 4 18:26:01 2020 +0100

    Fix issues

commit dad1d2c4d4eb37fdd23096a3344cf4f14498e335
Merge: 16cf0a3058 0a1ba511ea
Author: Laurent Cozic <laurent@cozic.net>
Date:   Sat Apr 4 18:09:46 2020 +0100

    Merge branch 'master' of https://github.com/fhfuih/joplin into fhfuih-master

commit 0a1ba511ea
Merge: 6207b42044 bdd760f343
Author: fhfuih <fhfuih@outlook.com>
Date:   Sat Mar 14 20:30:27 2020 -0400

    Merge branch 'master' into master

commit 6207b42044
Author: fhfuih <sam.zyhuang@outlook.com>
Date:   Sat Mar 14 20:13:28 2020 -0400

    Decryption Retry All RN frontend

commit 6f46d1985f
Author: fhfuih <sam.zyhuang@outlook.com>
Date:   Sat Mar 14 20:10:55 2020 -0400

    Decryption Retry All backend & desktop

commit 4c3d37b311
Author: fhfuih <sam.zyhuang@outlook.com>
Date:   Fri Mar 13 13:21:21 2020 -0400

    Revert "Add "retry all" option to synchronisation page"

    This reverts commit 15daaa16fd.

commit cffc919791
Author: fhfuih <sam.zyhuang@outlook.com>
Date:   Fri Mar 13 13:19:51 2020 -0400

    Revert "Refactor "retry all" renderer to avoid hacks"

    This reverts commit 51ba6ea655.

commit 51ba6ea655
Author: fhfuih <sam.zyhuang@outlook.com>
Date:   Tue Mar 10 18:27:22 2020 -0400

    Refactor "retry all" renderer to avoid hacks

commit 57d71712e1
Merge: 15daaa16fd b367955e56
Author: fhfuih <sam.zyhuang@outlook.com>
Date:   Mon Mar 9 20:42:02 2020 -0400

    Merge branch 'master' of https://github.com/fhfuih/joplin

commit 15daaa16fd
Author: fhfuih <sam.zyhuang@outlook.com>
Date:   Mon Mar 9 20:36:09 2020 -0400

    Add "retry all" option to synchronisation page
This commit is contained in:
Laurent Cozic 2020-04-04 18:30:13 +01:00
parent 16cf0a3058
commit f550d847c4
3 changed files with 41 additions and 1 deletions

View File

@ -47,6 +47,7 @@ class StatusScreenComponent extends React.Component {
const headerStyle = Object.assign({}, theme.headerStyle, { width: style.width });
const retryStyle = Object.assign({}, theme.urlStyle, { marginLeft: 5 });
const retryAllStyle = Object.assign({}, theme.urlStyle, { marginTop: 5, display: 'inline-block' });
const containerPadding = 10;
@ -63,6 +64,14 @@ class StatusScreenComponent extends React.Component {
);
}
function renderSectionRetryAllHtml(key, retryAllHandler) {
return (
<a key={`retry_all_${key}`} href="#" onClick={retryAllHandler} style={retryAllStyle}>
{_('Retry All')}
</a>
);
}
const renderSectionHtml = (key, section) => {
const itemsHtml = [];
@ -102,6 +111,10 @@ class StatusScreenComponent extends React.Component {
);
}
if (section.canRetryAll) {
itemsHtml.push(renderSectionRetryAllHtml(section.title, section.retryAllHandler));
}
return <div key={key}>{itemsHtml}</div>;
};

View File

@ -61,6 +61,9 @@ class StatusScreenComponent extends BaseScreenComponent {
style.fontWeight = 'bold';
if (i > 0) style.paddingTop = 20;
lines.push({ key: `section_${i}`, isSection: true, text: section.title });
if (section.canRetryAll) {
lines.push({ key: `retry_all_${i}`, text: '', retryAllHandler: section.retryAllHandler });
}
for (const n in section.body) {
if (!section.body.hasOwnProperty(n)) continue;
@ -101,6 +104,12 @@ class StatusScreenComponent extends BaseScreenComponent {
style.flex = 1;
const retryAllButton = item.retryAllHandler ? (
<View style={{ flex: 0 }}>
<Button title={_('Retry All')} onPress={item.retryAllHandler} />
</View>
) : null;
const retryButton = item.retryHandler ? (
<View style={{ flex: 0 }}>
<Button title={_('Retry')} onPress={item.retryHandler} />
@ -113,6 +122,7 @@ class StatusScreenComponent extends BaseScreenComponent {
return (
<View style={{ flex: 1, flexDirection: 'row' }}>
<Text style={style}>{item.text}</Text>
{retryAllButton}
{retryButton}
</View>
);

View File

@ -139,7 +139,7 @@ class ReportService {
const decryptionDisabledItems = await DecryptionWorker.instance().decryptionDisabledItems();
if (decryptionDisabledItems.length) {
section = { title: _('Items that cannot be decrypted'), body: [], name: 'failedDecryption' };
section = { title: _('Items that cannot be decrypted'), body: [], name: 'failedDecryption', canRetryAll: false, retryAllHandler: null };
section.body.push(_('Joplin failed to decrypt these items multiple times, possibly because they are corrupted or too large. These items will remain on the device but Joplin will no longer attempt to decrypt them.'));
@ -157,6 +157,23 @@ class ReportService {
});
}
const retryHandlers = [];
for (let i = 0; i < section.body.length; i++) {
if (section.body[i].canRetry) {
retryHandlers.push(section.body[i].retryHandler);
}
}
if (retryHandlers.length > 1) {
section.canRetryAll = true;
section.retryAllHandler = async () => {
for (const retryHandler of retryHandlers) {
await retryHandler();
}
};
}
sections.push(section);
}