Resolve issue where unable to scroll further after updating record RPS-65.
This commit is contained in:
@@ -66,12 +66,17 @@ body {
|
||||
// }
|
||||
.jobs-list-container {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
// padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.jobs-list-infinite-container {
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
height: 100%;
|
||||
flex: 1;
|
||||
padding-bottom: 30px;
|
||||
}
|
||||
|
||||
//Required for the tab with infinite loading
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { SyncOutlined } from "@ant-design/icons";
|
||||
import { useQuery } from "@apollo/client";
|
||||
import { Dropdown, List, Menu, Spin } from "antd";
|
||||
import { List } from "antd";
|
||||
import React, { useState } from "react";
|
||||
import InfiniteScroll from "react-infinite-scroller";
|
||||
import { QUERY_ALL_JOBS_PAGINATED } from "../../../graphql/jobs.queries";
|
||||
@@ -22,21 +21,14 @@ export default function JobsTableOrganism() {
|
||||
}
|
||||
);
|
||||
|
||||
const menu = (
|
||||
<Menu>
|
||||
<Menu.Item onClick={() => refetch()}>
|
||||
<SyncOutlined />
|
||||
Reload
|
||||
</Menu.Item>
|
||||
</Menu>
|
||||
);
|
||||
|
||||
const handleInfiniteOnLoad = (page) => {
|
||||
fetchMore &&
|
||||
fetchMore({
|
||||
const handleInfiniteOnLoad = async (page) => {
|
||||
console.log("Fetching more records!", page, fetchMore);
|
||||
if (fetchMore) {
|
||||
await fetchMore({
|
||||
variables: {
|
||||
offset: limit * page,
|
||||
},
|
||||
|
||||
updateQuery: (prev, { fetchMoreResult }) => {
|
||||
if (!fetchMoreResult) {
|
||||
console.log("No more results. Fetch More was empty.");
|
||||
@@ -49,8 +41,8 @@ export default function JobsTableOrganism() {
|
||||
});
|
||||
|
||||
if (
|
||||
newCache.jobs.length >= data &&
|
||||
data.jobs_aggregate.aggregate.count
|
||||
newCache.jobs.length >=
|
||||
(data && data.jobs_aggregate.aggregate.count)
|
||||
) {
|
||||
console.log("No more results.");
|
||||
setState({ ...state, hasMore: false });
|
||||
@@ -59,6 +51,11 @@ export default function JobsTableOrganism() {
|
||||
return newCache;
|
||||
},
|
||||
});
|
||||
// if (data.jobs.length >= data.jobs_aggregate.aggregate.count) {
|
||||
// console.log("No more results.");
|
||||
// setState({ ...state, hasMore: false });
|
||||
// }
|
||||
}
|
||||
};
|
||||
|
||||
if (error)
|
||||
@@ -77,22 +74,16 @@ export default function JobsTableOrganism() {
|
||||
loadMore={handleInfiniteOnLoad}
|
||||
hasMore={!loading && state.hasMore}
|
||||
useWindow={false}
|
||||
threshold={30}
|
||||
>
|
||||
<Dropdown overlay={menu} trigger={["contextMenu"]}>
|
||||
<List
|
||||
bordered
|
||||
dataSource={data ? [{ isRefresh: true }, ...data.jobs] : []}
|
||||
renderItem={(item) => (
|
||||
<JobsListItemMolecule item={item} refetch={refetch} />
|
||||
)}
|
||||
>
|
||||
{loading && state.hasMore && (
|
||||
<div>
|
||||
<Spin />
|
||||
</div>
|
||||
)}
|
||||
</List>
|
||||
</Dropdown>
|
||||
<List
|
||||
bordered
|
||||
loading={loading}
|
||||
dataSource={data ? [{ isRefresh: true }, ...data.jobs] : []}
|
||||
renderItem={(item) => (
|
||||
<JobsListItemMolecule item={item} refetch={refetch} />
|
||||
)}
|
||||
></List>
|
||||
</InfiniteScroll>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { SyncOutlined } from "@ant-design/icons";
|
||||
import { useLazyQuery } from "@apollo/client";
|
||||
import { Dropdown, List, Menu, Spin } from "antd";
|
||||
import { List, Spin } from "antd";
|
||||
import React, { useState } from "react";
|
||||
import InfiniteScroll from "react-infinite-scroller";
|
||||
import { SEARCH_JOBS_PAGINATED } from "../../../graphql/jobs.queries";
|
||||
@@ -8,37 +7,26 @@ import ErrorResultAtom from "../../atoms/error-result/error-result.atom";
|
||||
import JobsListItemMolecule from "../../molecules/jobs-list-item/jobs-list-item.molecule";
|
||||
import JobsSearchFieldsMolecule from "../../molecules/jobs-search-fields/jobs-search-fields.molecule";
|
||||
|
||||
|
||||
|
||||
const limit = 20;
|
||||
export default function JobsTableOrganism() {
|
||||
const [state, setState] = useState({ hasMore: true });
|
||||
|
||||
const [
|
||||
callSearch,
|
||||
{ loading, error, data, refetch, fetchMore },
|
||||
] = useLazyQuery(SEARCH_JOBS_PAGINATED, {
|
||||
variables: {
|
||||
offset: 0,
|
||||
limit: limit,
|
||||
},
|
||||
});
|
||||
|
||||
const menu = (
|
||||
<Menu>
|
||||
<Menu.Item onClick={() => refetch()}>
|
||||
<SyncOutlined />
|
||||
Reload
|
||||
</Menu.Item>
|
||||
</Menu>
|
||||
const [callSearch, { loading, error, data, fetchMore }] = useLazyQuery(
|
||||
SEARCH_JOBS_PAGINATED,
|
||||
{
|
||||
variables: {
|
||||
offset: 0,
|
||||
limit: limit,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const handleInfiniteOnLoad = (page) => {
|
||||
const handleInfiniteOnLoad = async (page) => {
|
||||
if (fetchMore) {
|
||||
// ipcRenderer.send(ipcTypes.default.app.toMain.track, {
|
||||
// event: "FETCH_MORE_JOBS",
|
||||
// });
|
||||
fetchMore({
|
||||
await fetchMore({
|
||||
variables: {
|
||||
offset: limit * page,
|
||||
},
|
||||
@@ -50,12 +38,12 @@ export default function JobsTableOrganism() {
|
||||
}
|
||||
|
||||
const newCache = Object.assign({}, prev, {
|
||||
jobs: [...prev.search_jobs, ...fetchMoreResult.search_jobs],
|
||||
search_jobs: [...prev.search_jobs, ...fetchMoreResult.search_jobs],
|
||||
});
|
||||
|
||||
if (
|
||||
newCache.jobs.length >= data &&
|
||||
data.search_jobs_aggregate.aggregate.count
|
||||
newCache.search_jobs.length >=
|
||||
(data && data.search_jobs_aggregate.aggregate.count)
|
||||
) {
|
||||
console.log("No more results.");
|
||||
setState({ ...state, hasMore: false });
|
||||
@@ -84,25 +72,21 @@ export default function JobsTableOrganism() {
|
||||
loadMore={handleInfiniteOnLoad}
|
||||
hasMore={!loading && state.hasMore}
|
||||
useWindow={false}
|
||||
threshold={30}
|
||||
>
|
||||
<Dropdown overlay={menu} trigger={["contextMenu"]}>
|
||||
<List
|
||||
bordered
|
||||
dataSource={data ? data.search_jobs : []}
|
||||
renderItem={(item) => <JobsListItemMolecule item={item} />}
|
||||
>
|
||||
{loading && state.hasMore && (
|
||||
<div>
|
||||
<Spin />
|
||||
</div>
|
||||
)}
|
||||
</List>
|
||||
</Dropdown>
|
||||
<List
|
||||
bordered
|
||||
dataSource={data ? data.search_jobs : []}
|
||||
renderItem={(item) => <JobsListItemMolecule item={item} />}
|
||||
>
|
||||
{loading && state.hasMore && (
|
||||
<div>
|
||||
<Spin />
|
||||
</div>
|
||||
)}
|
||||
</List>
|
||||
</InfiniteScroll>
|
||||
</div>
|
||||
{`${data ? data.search_jobs.length : 0} jobs loaded. ${
|
||||
data ? data.search_jobs_aggregate.aggregate.count : 0
|
||||
} total jobs.`}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ export const SEARCH_JOBS_PAGINATED = gql`
|
||||
}
|
||||
search_jobs_aggregate(
|
||||
args: { enddate: $endDate, search: $search, startdate: $startDate }
|
||||
where: { close_date: { _is_null: $closeDateIsNull } }
|
||||
) {
|
||||
aggregate {
|
||||
count(distinct: true)
|
||||
|
||||
@@ -53,7 +53,7 @@ ipcRenderer.on(
|
||||
ipcRenderer.on(
|
||||
ipcTypes.default.estimate.toRenderer.estimateDecodeSuccess,
|
||||
async (event, obj) => {
|
||||
console.log("obj", obj);
|
||||
|
||||
await UpsertEstimate(obj);
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user