Added further logging. RPS-4
This commit is contained in:
@@ -4,10 +4,13 @@ import { Dropdown, List, Menu, Spin } from "antd";
|
||||
import React, { useState } from "react";
|
||||
import InfiniteScroll from "react-infinite-scroller";
|
||||
import { SEARCH_JOBS_PAGINATED } from "../../../graphql/jobs.queries";
|
||||
import ipcTypes from "../../../ipc.types";
|
||||
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 { ipcRenderer } = window;
|
||||
|
||||
const limit = 20;
|
||||
export default function JobsTableOrganism() {
|
||||
const [state, setState] = useState({ hasMore: true });
|
||||
@@ -33,32 +36,35 @@ export default function JobsTableOrganism() {
|
||||
|
||||
const handleInfiniteOnLoad = (page) => {
|
||||
if (fetchMore)
|
||||
fetchMore({
|
||||
variables: {
|
||||
offset: limit * page,
|
||||
},
|
||||
updateQuery: (prev, { fetchMoreResult }) => {
|
||||
if (!fetchMoreResult) {
|
||||
console.log("No more results. Fetch More was empty.");
|
||||
setState({ ...state, hasMore: false });
|
||||
return prev;
|
||||
}
|
||||
|
||||
const newCache = Object.assign({}, prev, {
|
||||
jobs: [...prev.search_jobs, ...fetchMoreResult.search_jobs],
|
||||
});
|
||||
|
||||
if (
|
||||
newCache.jobs.length >= data &&
|
||||
data.search_jobs_aggregate.aggregate.count
|
||||
) {
|
||||
console.log("No more results.");
|
||||
setState({ ...state, hasMore: false });
|
||||
}
|
||||
|
||||
return newCache;
|
||||
},
|
||||
ipcRenderer.send(ipcTypes.default.app.toMain.track, {
|
||||
event: "FETCH_MORE_JOBS",
|
||||
});
|
||||
fetchMore({
|
||||
variables: {
|
||||
offset: limit * page,
|
||||
},
|
||||
updateQuery: (prev, { fetchMoreResult }) => {
|
||||
if (!fetchMoreResult) {
|
||||
console.log("No more results. Fetch More was empty.");
|
||||
setState({ ...state, hasMore: false });
|
||||
return prev;
|
||||
}
|
||||
|
||||
const newCache = Object.assign({}, prev, {
|
||||
jobs: [...prev.search_jobs, ...fetchMoreResult.search_jobs],
|
||||
});
|
||||
|
||||
if (
|
||||
newCache.jobs.length >= data &&
|
||||
data.search_jobs_aggregate.aggregate.count
|
||||
) {
|
||||
console.log("No more results.");
|
||||
setState({ ...state, hasMore: false });
|
||||
}
|
||||
|
||||
return newCache;
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
if (error)
|
||||
|
||||
Reference in New Issue
Block a user