Fix loading detection

This commit is contained in:
Rene Pfeuffer
2020-02-21 07:37:55 +01:00
parent c4a801a7be
commit 264f6efd04

View File

@@ -105,7 +105,6 @@ class FileTree extends React.Component<Props, State> {
return (
<div className="panel-block">
{this.renderSourcesTable()}
{lastHunk.loading && <Loading />}
{lastHunk.tree?.truncated && <Button label={t("sources.loadMore")} action={this.loadMore} />}
</div>
);
@@ -124,6 +123,10 @@ class FileTree extends React.Component<Props, State> {
});
}
if (hunks.every(hunk => hunk.loading)) {
return <Loading />;
}
hunks
.filter(hunk => !hunk.loading)
.forEach(hunk => {
@@ -144,6 +147,7 @@ class FileTree extends React.Component<Props, State> {
}
return (
<>
<table className="table table-hover table-sm is-fullwidth">
<thead>
<tr>
@@ -161,6 +165,8 @@ class FileTree extends React.Component<Props, State> {
))}
</tbody>
</table>
{hunks[hunks.length - 1].loading && <Loading />}
</>
);
}
return <Notification type="info">{t("sources.noSources")}</Notification>;
@@ -185,7 +191,6 @@ const mapStateToProps = (state: any, ownProps: Props) => {
const hunkCount = getHunkCount(state, repository, revision, path);
const hunks = [];
for (let i = 0; i < hunkCount; ++i) {
console.log(`getting data for hunk ${i}`);
const tree = getSources(state, repository, revision, path, i);
const loading = isFetchSourcesPending(state, repository, revision, path, i);
hunks.push({