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: Session expired exception was thrown after reopening a screen #1967

Merged
merged 4 commits into from Sep 26, 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
4 changes: 4 additions & 0 deletions frontend-html/src/model/entities/DataSource.ts
Expand Up @@ -51,4 +51,8 @@ export class DataSource implements IDataSource {
getFieldByIndex(index: number): IDataSourceField | undefined {
return this.fields.find(field => field.index === index);
}

dispose(){
this.rowState.dispose();
}
}
7 changes: 6 additions & 1 deletion frontend-html/src/model/entities/FormScreen.ts
Expand Up @@ -251,8 +251,13 @@ export class FormScreen implements IFormScreen {
console.log("End of View bindings");
console.log("");
}

/* eslint-enable no-console */

dispose(){
for (let dataSource of this.dataSources) {
dataSource.dispose();
}
}
}

export class FormScreenEnvelope implements IFormScreenEnvelope {
Expand Down
8 changes: 7 additions & 1 deletion frontend-html/src/model/entities/RowState.ts
Expand Up @@ -40,12 +40,13 @@ export class RowState implements IRowState {
$type_IRowState: 1 = 1;
suppressWorkingStatus: boolean = false;
dataViewVisibleRows: Map<string,string[]> = new Map();
disposers: (()=> void)[] = [];

constructor(debouncingDelayMilliseconds?: number) {
this.triggerLoadDebounced = _.debounce(
this.triggerLoadImm,
debouncingDelayMilliseconds == undefined ? 0 : debouncingDelayMilliseconds);
visibleRowsChanged.subscribe((visibleRows) => {
const disposer = visibleRowsChanged.subscribe((visibleRows) => {
const dataSource = getDataSource(this);
if (!visibleRows || dataSource.identifier !== visibleRows.dataSourceId) {
return;
Expand All @@ -59,6 +60,7 @@ export class RowState implements IRowState {
this.triggerLoadDebounced();
}
});
this.disposers.push(disposer);
}

monitor: FlowBusyMonitor = new FlowBusyMonitor();
Expand Down Expand Up @@ -257,6 +259,10 @@ export class RowState implements IRowState {
// TODO: Wait when something is currently loading.
}

dispose(){
this.disposers.forEach(x => x());
}

parent?: any;
}

Expand Down
Expand Up @@ -386,6 +386,7 @@ export class WorkbenchLifecycle implements IWorkbenchLifecycle {
const api = getApi(this);
if (openedScreen.content) {
if (openedScreen.content.formScreen) {
openedScreen.content.formScreen.dispose();
yield api.destroyUI({FormSessionId: getSessionId(openedScreen.content.formScreen)});
} else if (openedScreen.content.preloadedSessionId) {
yield api.destroyUI({FormSessionId: openedScreen.content.preloadedSessionId});
Expand Down
2 changes: 2 additions & 0 deletions frontend-html/src/model/entities/types/IDataSource.ts
Expand Up @@ -37,6 +37,8 @@ export interface IDataSource extends IDataSourceData {
getFieldByIndex(idex: number): IDataSourceField | undefined;

parent?: any;

dispose(): void;
}

export const isIDataSource = (o: any): o is IDataSource => o.$type_IDataSource;
2 changes: 2 additions & 0 deletions frontend-html/src/model/entities/types/IFormScreen.ts
Expand Up @@ -184,6 +184,8 @@ export interface IFormScreen extends IFormScreenData {
printMasterDetailTree(): void;

parent?: any;

dispose(): void;
}

export interface IScreenNotification {
Expand Down
2 changes: 2 additions & 0 deletions frontend-html/src/model/entities/types/IRowState.ts
Expand Up @@ -41,6 +41,8 @@ export interface IRowState extends IRowStateData {
reload(): void;

parent?: any;

dispose(): void;
}

export interface IRowStateItem {
Expand Down