Skip to content

Commit

Permalink
ensure basket feature tables suspend and resume at right time (finos#969
Browse files Browse the repository at this point in the history
)
  • Loading branch information
heswell authored Nov 14, 2023
1 parent 8753c6f commit 6a24965
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 19 deletions.
2 changes: 2 additions & 0 deletions vuu-ui/packages/vuu-data/src/inlined-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -1876,11 +1876,13 @@ var ServerProxy = class {
this.sendIfReady(request, requestId, viewport.status === "subscribed");
}
disableViewport(viewport) {
console.log("disable viewport");
const requestId = nextRequestId();
const request = viewport.disable(requestId);
this.sendIfReady(request, requestId, viewport.status === "subscribed");
}
enableViewport(viewport) {
console.log("enable viewport");
if (viewport.disabled) {
const requestId = nextRequestId();
const request = viewport.enable(requestId);
Expand Down
2 changes: 2 additions & 0 deletions vuu-ui/packages/vuu-data/src/remote-data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ export class RemoteDataSource
}

suspend() {
console.log(`suspend #${this.viewport}, current status ${this.#status}`);
info?.(`suspend #${this.viewport}, current status ${this.#status}`);
if (this.viewport) {
this.#status = "suspended";
Expand Down Expand Up @@ -266,6 +267,7 @@ export class RemoteDataSource
}

disable() {
console.log(`disable #${this.viewport}, current status ${this.#status}`);
info?.(`disable #${this.viewport}, current status ${this.#status}`);
if (this.viewport) {
this.#status = "disabling";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export const LayoutManagementProvider = (

const saveApplicationLayout = useCallback(
(layout: LayoutJSON) => {
console.log(`save application layout ${JSON.stringify(layout, null, 2)}`);
const persistenceManager = getPersistenceManager();
setApplicationLayout(layout, false);
persistenceManager.saveApplicationLayout(layout);
Expand Down
20 changes: 10 additions & 10 deletions vuu-ui/packages/vuu-table/src/table-next/useDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,16 @@ export const useDataSource = ({

const setData = useCallback(
(updates: DataSourceRow[]) => {
console.table(updates);
for (const row of updates) {
dataWindow.add(row);
}
data.current = dataWindow.data;
if (isMounted.current) {
// TODO do we ever need to worry about missing updates here ?
forceUpdate({});
} else {
console.log(`ignore update as we're not mounted`);
}
},
[dataWindow]
Expand Down Expand Up @@ -84,17 +87,14 @@ export const useDataSource = ({
return dataWindow.getSelectedRows();
}, [dataWindow]);

useEffect(
() => () => {
isMounted.current = true;
// if (rafHandle.current) {
// cancelAnimationFrame(rafHandle.current);
// rafHandle.current = null;
// }
useEffect(() => {
isMounted.current = true;
dataSource.resume?.();
return () => {
isMounted.current = false;
},
[]
);
dataSource.suspend?.();
};
}, [dataSource]);

// Keep until we'tre sure we don't need it for updates
// const refreshIfUpdated = useCallback(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ActiveItemChangeHandler, useViewContext } from "@finos/vuu-layout";
import { useShellContext } from "@finos/vuu-shell";
import { applyDefaultColumnConfig } from "@finos/vuu-utils";
import { Button } from "@salt-ds/core";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { useCallback, useMemo, useRef, useState } from "react";
import { useSessionDataSource } from "./useSessionDataSource";
import { FilterTableFeatureProps } from "./VuuFilterTableFeature";

Expand Down Expand Up @@ -161,13 +161,6 @@ export const useFilterTable = ({ tableSchema }: FilterTableFeatureProps) => {
[load]
);

useEffect(() => {
dataSource.resume?.();
return () => {
dataSource.suspend?.();
};
}, [dataSource]);

const { buildViewserverMenuOptions, handleMenuAction } = useVuuMenuActions({
dataSource,
menuActionConfig,
Expand Down

0 comments on commit 6a24965

Please sign in to comment.