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

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

This reverts commit 51ba6ea655.
This commit is contained in:
fhfuih 2020-03-13 13:19:51 -04:00
parent 51ba6ea655
commit cffc919791

View File

@ -55,6 +55,8 @@ class StatusScreenComponent extends React.Component {
height: style.height - theme.headerHeight - containerPadding * 2, height: style.height - theme.headerHeight - containerPadding * 2,
}); });
let retryHandlers = [];
function renderSectionTitleHtml(key, title) { function renderSectionTitleHtml(key, title) {
return ( return (
<h2 key={`section_${key}`} style={theme.h2Style}> <h2 key={`section_${key}`} style={theme.h2Style}>
@ -81,6 +83,8 @@ class StatusScreenComponent extends React.Component {
this.resfreshScreen(); this.resfreshScreen();
}; };
retryHandlers.push(item.retryHandler);
retryLink = ( retryLink = (
<a href="#" onClick={onClick} style={retryStyle}> <a href="#" onClick={onClick} style={retryStyle}>
{_('Retry')} {_('Retry')}
@ -105,24 +109,13 @@ class StatusScreenComponent extends React.Component {
return <div key={key}>{itemsHtml}</div>; return <div key={key}>{itemsHtml}</div>;
}; };
function renderRetryAllHtml(report) { function renderRetryAllHtml() {
let retryHandlers = [];
let retryAllLink = null; let retryAllLink = null;
report.forEach(section => {
section.body.forEach(item => {
if (item.canRetry) {
retryHandlers.push(item.retryHandler);
}
});
});
if (retryHandlers.length > 1) { if (retryHandlers.length > 1) {
const onClick = async () => { const onClick = async () => {
await Promise.all(retryHandlers.map(handler => handler())); await Promise.all(retryHandlers.map(handler => handler()));
this.resfreshScreen(); this.resfreshScreen();
}; };
retryAllLink = ( retryAllLink = (
<div> <div>
<a href="#" onClick={onClick} style={retryStyle}> <a href="#" onClick={onClick} style={retryStyle}>
@ -143,7 +136,7 @@ class StatusScreenComponent extends React.Component {
sectionsHtml.push(renderSectionHtml(i, section)); sectionsHtml.push(renderSectionHtml(i, section));
} }
let retryAllHtml = renderRetryAllHtml(report); let retryAllHtml = renderRetryAllHtml(); // must be called after renderSectionHtml
return ( return (
<div> <div>