@opengeoweb/webmap-react 9.33.0 → 9.33.1-spike-ol.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.esm.js +32 -31
  2. package/package.json +1 -1
package/index.esm.js CHANGED
@@ -9820,15 +9820,11 @@ class ReactMapView extends React.Component {
9820
9820
  const autoFetchInterval = Number(shouldAutoFetch); // Default true -> 1 minute
9821
9821
  const autoFetchIntervalMilliSeconds = Math.abs(autoFetchInterval) * MINUTE_TO_MILLISECOND;
9822
9822
  if (document.visibilityState === 'visible') {
9823
- if (this.lastRefetched &&
9824
- // skip if last refetch was within 1 minute (or the autoFetchInterval)
9825
- new Date().getTime() - this.lastRefetched > autoFetchIntervalMilliSeconds) {
9823
+ // Check if the last refetch time is not set or if the time since the last refetch exceeds the interval
9824
+ if (!this.lastRefetched || new Date().getTime() - this.lastRefetched > autoFetchIntervalMilliSeconds) {
9825
+ // Refetch immediately and restart the timer
9826
9826
  this.onStartRefetchTimer(true);
9827
- } else {
9828
- this.onStartRefetchTimer();
9829
9827
  }
9830
- } else {
9831
- this.clearRefetchTimer();
9832
9828
  }
9833
9829
  };
9834
9830
  /**
@@ -9846,31 +9842,36 @@ class ReactMapView extends React.Component {
9846
9842
  this.clearRefetchTimer();
9847
9843
  const autoFetchInterval = Number(shouldAutoFetch); // Default true -> 1 minute
9848
9844
  const refetch = () => {
9849
- this.lastRefetched = new Date().getTime();
9850
- const {
9851
- mapId
9852
- } = this.props;
9853
- const wmjsMap = webmapUtils.getWMJSMapById(mapId);
9854
- const layers = wmjsMap == null ? void 0 : wmjsMap.getLayers();
9855
- layers == null || layers.forEach(layer => {
9856
- if (layer.enabled !== false) {
9857
- parseWMJSLayer(layer, true).then(wmLayer => {
9858
- const {
9859
- props
9860
- } = this;
9861
- const {
9862
- mapId,
9863
- onUpdateLayerInformation
9864
- } = props;
9865
- const layerInfo = getLayerUpdateInfo(wmLayer, mapId);
9866
- onUpdateLayerInformation && onUpdateLayerInformation(layerInfo);
9867
- }).catch(e => {
9868
- console.error(e);
9869
- });
9870
- }
9871
- });
9845
+ const isVisible = document.visibilityState === 'visible';
9846
+ if (isVisible) {
9847
+ this.lastRefetched = new Date().getTime();
9848
+ const {
9849
+ mapId
9850
+ } = this.props;
9851
+ const wmjsMap = webmapUtils.getWMJSMapById(mapId);
9852
+ const layers = wmjsMap == null ? void 0 : wmjsMap.getLayers();
9853
+ layers == null || layers.forEach(layer => {
9854
+ if (layer.enabled !== false) {
9855
+ parseWMJSLayer(layer, true).then(wmLayer => {
9856
+ const {
9857
+ props
9858
+ } = this;
9859
+ const {
9860
+ mapId,
9861
+ onUpdateLayerInformation
9862
+ } = props;
9863
+ const layerInfo = getLayerUpdateInfo(wmLayer, mapId);
9864
+ onUpdateLayerInformation && onUpdateLayerInformation(layerInfo);
9865
+ }).catch(e => {
9866
+ console.error(e);
9867
+ });
9868
+ }
9869
+ });
9870
+ }
9872
9871
  };
9873
- this.refetchTimer = setInterval(refetch, Math.abs(autoFetchInterval) * MINUTE_TO_MILLISECOND);
9872
+ if (autoFetchInterval > 0) {
9873
+ this.refetchTimer = setInterval(refetch, Math.abs(autoFetchInterval) * MINUTE_TO_MILLISECOND);
9874
+ }
9874
9875
  if (force) {
9875
9876
  refetch();
9876
9877
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/webmap-react",
3
- "version": "9.33.0",
3
+ "version": "9.33.1-spike-ol.3",
4
4
  "description": "GeoWeb react wrapper for webmap",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {