Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Busy indicator was not active right after row states were requested 2022.4 #1778

Merged
merged 3 commits into from Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 14 additions & 1 deletion frontend-html/src/gui/connections/CScreenHeader.tsx
Expand Up @@ -36,6 +36,7 @@ import { T } from "utils/translation";
import { ErrorBoundaryEncapsulated } from "gui/Components/Utilities/ErrorBoundary";
import { IOpenedScreen } from "model/entities/types/IOpenedScreen";
import { getActiveScreen } from "model/selectors/getActiveScreen";
import {getRowStates} from "../../model/selectors/RowState/getRowStates";

@observer
export class CScreenHeader extends React.Component {
Expand All @@ -60,6 +61,15 @@ export class CScreenHeader extends React.Component {

@observer
class CScreenHeaderInner extends React.Component<{ activeScreen: IOpenedScreen }> {

areRowStatesLoading(){
const dataViews = this.props.activeScreen.content.formScreen?.dataViews;
if(!dataViews){
return false;
}
return dataViews.some(dataView => getRowStates(dataView).isWorking)
}

render() {
const {activeScreen} = this.props;
const {content} = activeScreen;
Expand All @@ -71,7 +81,10 @@ class CScreenHeaderInner extends React.Component<{ activeScreen: IOpenedScreen }
<>
<h1 className={"printOnly"}>{activeScreen.formTitle}</h1>
<ScreenHeader
isLoading={content.isLoading || getIsScreenOrAnyDataViewWorking(content.formScreen!)}
isLoading={
content.isLoading ||
getIsScreenOrAnyDataViewWorking(content.formScreen!) ||
this.areRowStatesLoading()}
>
<h1>{activeScreen.formTitle}</h1>
{(isCancelButton || isNextButton) && <ScreenheaderDivider/>}
Expand Down
1 change: 0 additions & 1 deletion frontend-html/src/model/entities/DataView.ts
Expand Up @@ -421,7 +421,6 @@ export class DataView implements IDataView {
@computed get isWorking() {
return (
this.lifecycle.isWorking ||
getRowStates(this).isWorking ||
getLookupLoader(this).isWorking
);
}
Expand Down
22 changes: 20 additions & 2 deletions frontend-html/src/model/entities/RowState.ts
Expand Up @@ -28,6 +28,7 @@ import { FlowBusyMonitor } from "../../utils/flow";
import { handleError } from "model/actions/handleError";

const maxRowStatesInOneCall = 100;
const loadingDelay = 666;

export enum IIdState {
LOADING = "LOADING",
Expand All @@ -44,8 +45,12 @@ export class RowState implements IRowState {

monitor: FlowBusyMonitor = new FlowBusyMonitor();

@observable
_isWorking = false;
workingTimeout: NodeJS.Timeout | undefined;

get isWorking() {
return this.monitor.isWorkingDelayed;
return this.monitor.isWorkingDelayed || this._isWorking;
}

@observable firstLoadingPerformed = false;
Expand Down Expand Up @@ -120,11 +125,14 @@ export class RowState implements IRowState {
}.bind(this)
);

triggerLoad = _.debounce(this.triggerLoadImm, 666);
triggerLoad = _.debounce(this.triggerLoadImm, loadingDelay);

getValue(rowId: string) {
if (!this.containers.has(rowId)) {
this.containers.set(rowId, new RowStateContainer(rowId));
if (!this.suppressWorkingStatus) {
this.setWorkingStatus();
}
}
let container = this.containers.get(rowId)!;
if (!container.atom) {
Expand All @@ -147,6 +155,16 @@ export class RowState implements IRowState {
}
}

private setWorkingStatus() {
clearTimeout(this.workingTimeout)
this.workingTimeout = setTimeout(() => {
this._isWorking = true;
});
this.workingTimeout = setTimeout(() => {
this._isWorking = false;
}, loadingDelay);
}

async loadValues(rowIds: string[]) {
for (const rowId of rowIds) {
if (!this.containers.has(rowId)) {
Expand Down