Skip to content

Commit

Permalink
Merge branch 'devel' into CB-5584-provide-more-information-in-the-deb…
Browse files Browse the repository at this point in the history
…ug-log-for-auditing
  • Loading branch information
EvgeniaBzzz authored Nov 21, 2024
2 parents 738f5a9 + 94aaf7b commit 60ff848
Showing 1 changed file with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { useService } from '@cloudbeaver/core-di';
import { EventContext, EventStopPropagationFlag } from '@cloudbeaver/core-events';
import { Executor } from '@cloudbeaver/core-executor';
import { ClipboardService } from '@cloudbeaver/core-ui';
import { throttle } from '@cloudbeaver/core-utils';
import { useCaptureViewContext } from '@cloudbeaver/core-view';
import { type CellSelectArgs, DataGrid, type DataGridHandle, type Position } from '@cloudbeaver/plugin-data-grid';
import {
Expand Down Expand Up @@ -52,8 +53,8 @@ interface IInnerState {
}

function isAtBottom(event: React.UIEvent<HTMLDivElement>): boolean {
const target = event.target as HTMLDivElement;
return target.clientHeight + target.scrollTop + 100 > target.scrollHeight;
const { clientHeight, scrollTop, scrollHeight } = event.target as HTMLDivElement;
return clientHeight + scrollTop + 100 > scrollHeight;
}

const rowHeight = 25;
Expand Down Expand Up @@ -410,23 +411,21 @@ export const DataGridTable = observer<IDataPresentationProps>(function DataGridT
};

const handleScroll = useCallback(
async (event: React.UIEvent<HTMLDivElement>) => {
const target = event.target as HTMLDivElement;
const toBottom = target.scrollTop > innerState.lastScrollTop;
throttle(async (event: React.UIEvent<HTMLDivElement>) => {
const scrollTop = (event.target as HTMLDivElement).scrollTop;
const toBottom = scrollTop > innerState.lastScrollTop;

innerState.lastScrollTop = target.scrollTop;
innerState.lastScrollTop = scrollTop;

if (!toBottom || !isAtBottom(event)) {
return;
}
if (toBottom && isAtBottom(event)) {
const result = model.source.getResult(resultIndex);
if (result?.loadedFully) {
return;
}

const result = model.source.getResult(resultIndex);
if (result?.loadedFully) {
return;
await model.requestDataPortion(0, model.countGain + model.source.count);
}

await model.requestDataPortion(0, model.countGain + model.source.count);
},
}, 200),
[model, resultIndex],
);

Expand Down

0 comments on commit 60ff848

Please sign in to comment.