Skip to content

Commit 935c9c6

Browse files
feat(gallery-web): fix derivedLoader to correctly update isRefreshing
1 parent 573ef49 commit 935c9c6

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
@@ -89,13 +89,7 @@ export class GalleryStore extends BaseControllerHost {
8989
host: this._sortHost
9090
};
9191

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

10094
new RefreshController(this, {
10195
delay: 0,

0 commit comments

Comments
 (0)