Skip to content

Commit

Permalink
fix(verify): resolve tagging issues (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
nmcharlton authored Dec 13, 2021
1 parent b124a97 commit c6d1baf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 206 deletions.
31 changes: 4 additions & 27 deletions src/components/Verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,6 @@ const Verify = (props) => {
const refContainer = useRef();
const numFilters = verifyContext.filter.countAppliedFilters();

// log.debug(
// 'render: verify',
// 'captures:',
// verifyContext.captureImages.length,
// 'species:',
// speciesContext.speciesList.length,
// 'tags:',
// tagsContext.tagList.length,
// );

/*
* effect to load page when mounted
*/
Expand All @@ -192,14 +182,6 @@ const Verify = (props) => {
setComplete(verifyContext.approveAllComplete);
}, [verifyContext.approveAllComplete]);

/* load more captures when the page or page size changes */
useEffect(() => {
// console.log('-- load images', verifyContext.filter);
const abortController = new AbortController();
verifyContext.loadCaptureImages({ signal: abortController.signal });
return () => abortController.abort();
}, [verifyContext.filter, verifyContext.pageSize, verifyContext.currentPage]);

function handleCaptureClick(e, captureId) {
e.stopPropagation();
e.preventDefault();
Expand Down Expand Up @@ -256,7 +238,6 @@ const Verify = (props) => {
} else if (!approveAction.rememberSelection) {
resetApprovalFields();
}
verifyContext.loadCaptureImages();
}

async function handleShowGrowerDetail(e, capture) {
Expand Down Expand Up @@ -292,6 +273,7 @@ const Verify = (props) => {
}

function handleChangePageSize(event) {
verifyContext.setCurrentPage(0);
verifyContext.setPageSize(event.target.value);
}

Expand All @@ -303,15 +285,10 @@ const Verify = (props) => {
return verifyContext.captureImagesSelected.indexOf(id) >= 0;
}

const captureImages = verifyContext.captureImages.filter((capture, index) => {
return (
index >= verifyContext.currentPage * verifyContext.pageSize &&
index < (verifyContext.currentPage + 1) * verifyContext.pageSize
);
});
const captureImages = verifyContext.captureImages;

const placeholderImages = verifyContext.isLoading
? Array(verifyContext.pageSize - captureImages.length)
? Array(Math.max(verifyContext.pageSize - captureImages.length, 0))
.fill()
.map((_, index) => {
return {
Expand Down Expand Up @@ -406,7 +383,7 @@ const Verify = (props) => {

let imagePagination = (
<TablePagination
rowsPerPageOptions={[12, 24, 48, 96, 192]}
rowsPerPageOptions={[24, 96, 192, 384]}
component="div"
count={verifyContext.captureCount || 0}
rowsPerPage={verifyContext.pageSize}
Expand Down
Loading

0 comments on commit c6d1baf

Please sign in to comment.