Skip to content

Commit

Permalink
Merge pull request #160 from openmsupply/#117-debounce-column-sort
Browse files Browse the repository at this point in the history
Debounce sort
  • Loading branch information
josh-griffin authored Jun 1, 2021
2 parents dcba0c7 + ca2f054 commit e56a1a9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ui/layouts/SensorLogsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Row } from './Row';
import { Centered } from './Centered';
import { LogTableAction, LogTableSelector } from '../../features';
import { Icon, ICON_SIZE } from '../presentation/icons';
import { debounce } from 'lodash';

const COLUMNS: Column[] = [
{ header: 'Timestamp', flex: 1, key: 'timestamp', textAlign: 'left', sortable: true },
Expand Down Expand Up @@ -136,12 +137,13 @@ const Header = ({ columns }: HeaderProps) => {
>
{columns.map(column => {
const { key, sortable, header, flex, textAlign } = column;
const sortData = debounce(() => dispatch(LogTableAction.trySortData(key)), 500);

return (
<MaybeTouchableContainer
isDisabled={!sortable}
style={{ flex }}
onPress={() => dispatch(LogTableAction.trySortData(key))}
onPress={sortData}
>
<Row
flex={flex}
Expand Down

0 comments on commit e56a1a9

Please sign in to comment.