Skip to content

Commit 28008d1

Browse files
feat(gallery-web): fix derivedLoader to correctly update isRefreshing
1 parent cab1967 commit 28008d1

File tree

3 files changed

+15
-22
lines changed

3 files changed

+15
-22
lines changed

packages/pluggableWidgets/gallery-web/src/Gallery.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ const Container = observer(function GalleryContainer(props: GalleryContainerProp
9191
focusController={focusController}
9292
getPosition={getPositionCallback}
9393
loadMoreButtonCaption={props.loadMoreButtonCaption?.value}
94+
showRefreshIndicator={rootStore.loaderCtrl.showRefreshIndicator}
9495
/>
9596
);
9697
});
Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
1-
type DerivedLoaderControllerSpec = {
2-
refreshIndicator: boolean;
3-
query: {
4-
isRefreshing: boolean;
5-
isSilentRefresh: boolean;
6-
};
7-
};
1+
import { DatasourceController } from "@mendix/widget-plugin-grid/query/DatasourceController";
2+
import { makeObservable, computed } from "mobx";
83

94
export class DerivedLoaderController {
10-
constructor(private spec: DerivedLoaderControllerSpec) {}
5+
constructor(
6+
private datasourceController: DatasourceController,
7+
private refreshIndicator: boolean
8+
) {
9+
makeObservable(this, {
10+
isRefreshing: computed,
11+
showRefreshIndicator: computed
12+
});
13+
}
1114

1215
get isRefreshing(): boolean {
13-
const { isSilentRefresh, isRefreshing } = this.spec.query;
14-
16+
const { isSilentRefresh, isRefreshing } = this.datasourceController;
1517
return !isSilentRefresh && isRefreshing;
1618
}
1719

1820
get showRefreshIndicator(): boolean {
19-
if (!this.spec.refreshIndicator) {
20-
return false;
21-
}
22-
23-
return this.isRefreshing;
21+
return this.refreshIndicator && this.isRefreshing;
2422
}
2523
}

packages/pluggableWidgets/gallery-web/src/stores/GalleryStore.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,7 @@ export class GalleryStore extends BaseControllerHost {
8787
host: this._sortHost
8888
};
8989

90-
this.loaderCtrl = new DerivedLoaderController({
91-
refreshIndicator: spec.refreshIndicator,
92-
query: {
93-
isRefreshing: this._query.isRefreshing,
94-
isSilentRefresh: this._query.isSilentRefresh
95-
}
96-
});
90+
this.loaderCtrl = new DerivedLoaderController(this._query, spec.refreshIndicator);
9791

9892
new RefreshController(this, {
9993
delay: 0,

0 commit comments

Comments
 (0)