Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { Slide } from 'react-slideshow-image';
import { ChevronLeft, FullScreen } from '../../icons';
import { Box, Button, Typography } from '@mui/material';
import { getInstanceByID } from '../../reducers/actions/instances';
import { getInstanceByID, clearUrlLoadingState } from '../../reducers/actions/instances';
import Modal from '../../shared/modal/Modal';
import 'react-slideshow-image/dist/styles.css'

Expand Down Expand Up @@ -115,12 +115,16 @@
});
const [isLoading, setIsLoading] = useState(false);
const reduxState = useSelector(state => state);
const misalignedTemplate = useSelector(state => state.globalInfo.misalignedTemplate)
const alignedTemplates = useSelector(state => state.globalInfo.alignedTemplates)
const misalignedIDs = useSelector(state => state.globalInfo.misalignedIDs)

const handleConfirmLoad = async () => {
if (!confirmationModal.example) return;

setIsLoading(true);
try {
clearUrlLoadingState()
window.open(
window.location.origin + '/?id=' + confirmationModal.example.template + '&i=' + confirmationModal.example.id,
'_blank'
Expand Down Expand Up @@ -159,6 +163,18 @@
}
}


useEffect(() => {
if ( misalignedTemplate && !alignedTemplates ){
setConfirmationModal({
open: true,
example: { id : Object.keys(misalignedIDs) , template: misalignedTemplate },
message: `The image you requested is aligned to another template. Click Load Template to open it in a new tab or Cancel to just view the image metadata.`
});
}
}, [misalignedTemplate, misalignedIDs])

Check warning on line 175 in applications/virtual-fly-brain/frontend/src/components/TermInfo/TerminfoSlider.jsx

View workflow job for this annotation

GitHub Actions / eslint

React Hook useEffect has a missing dependency: 'alignedTemplates'. Either include it or remove the dependency array

Check warning on line 175 in applications/virtual-fly-brain/frontend/src/components/TermInfo/TerminfoSlider.jsx

View workflow job for this annotation

GitHub Actions / eslint

React Hook useEffect has a missing dependency: 'alignedTemplates'. Either include it or remove the dependency array
Comment thread
jrmartin marked this conversation as resolved.
Outdated


useEffect( () => {
if(props?.examples) {
const images = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ const GlobalReducer = (state = initialStateGlobalReducer, response) => {
})
case getGlobalTypes.ALIGN_TEMPLATES:{
const aligned = response.payload.aligned;
const id = response.payload.templateID
const templateID = response.payload.templateID
const id = response.payload.id
return Object.assign({}, state, {
alignedTemplates: aligned,
misalignedTemplate : id,
misalignedTemplate : templateID,
misalignedIDs : {...state.misalignedIDs, [id] : id }
Comment thread
jrmartin marked this conversation as resolved.
Outdated
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,7 @@ const InstancesReducer = (state = initialStateInstancesReducer, response) => {
case getInstancesTypes.CLEAR_URL_LOADING_STATE: {
return Object.assign({}, state, {
isLoadingFromUrl: false,
isLoading: false,
});
}
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ export const setFirstIDLoaded = () => ({
payload : {}
})

export const setAlignTemplates = (aligned, templateID) => ({
export const setAlignTemplates = (aligned, id, templateID) => ({
type: getGlobalTypes.ALIGN_TEMPLATES,
payload : { aligned, templateID }
payload : { aligned, id, templateID }
})
Comment thread
jrmartin marked this conversation as resolved.

export const setTemplateID = (id) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,10 @@ export const setBulkLoadingCount = (count, isFromUrl = false) => ({
payload: { count, isFromUrl }
});

export const clearUrlLoadingState = () => ({
type: getInstancesTypes.CLEAR_URL_LOADING_STATE
});
export const clearUrlLoadingState = () => {
store.dispatch({type: getInstancesTypes.CLEAR_URL_LOADING_STATE});
return;
};
Comment thread
jrmartin marked this conversation as resolved.

export const resetBulkLoading = () => ({
type: getInstancesTypes.RESET_BULK_LOADING
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,14 @@ export const urlUpdaterMiddleware = store => next => (action) => {
await focusInstance(pendingFocusId);
await selectInstance(pendingFocusId);
// Clear URL loading state after async operations complete
store.dispatch(clearUrlLoadingState());
clearUrlLoadingState();
// Clear the initial focus ID after a longer delay to allow all pending template operations to complete
setTimeout(() => {
initialUrlFocusId = null;
}, 1000);
})();
} else {
store.dispatch(clearUrlLoadingState());
clearUrlLoadingState();
}
Comment thread
jrmartin marked this conversation as resolved.
}

Expand Down Expand Up @@ -272,7 +272,7 @@ export const urlUpdaterMiddleware = store => next => (action) => {
return;
}
// If the individual is not aligned with the current template, we need to show the misalignment dialog
store.dispatch(setAlignTemplates(false, action.payload.Id));
store.dispatch(setAlignTemplates(false, action.payload.Id, Object.keys(action.payload?.Images)|| Object.keys(action.payload?.Examples || {})));
Comment thread
jrmartin marked this conversation as resolved.
return;
Comment thread
jrmartin marked this conversation as resolved.
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const SubHeader = ({ setBottomNav, bottomNav }) => {
const [filterOpened, setFilterOpened] = useState(false);
const [selectedFilters, setSelectedFilters] = useState({});
const [desktop, setDesktop] = useState(window.innerWidth >= 1200);
const [isLoading, setIsLoading] = useState(false);

useEffect(() => {
const handleResize = () => {
Expand All @@ -89,7 +90,6 @@ const SubHeader = ({ setBottomNav, bottomNav }) => {
return () => window.removeEventListener("resize", handleResize);
}, []);

const isLoading = useSelector((state) => state.instances.isLoading);
const loadingInstances = useSelector(
(state) => state.instances.loadingInstances
);
Expand Down Expand Up @@ -123,6 +123,12 @@ const SubHeader = ({ setBottomNav, bottomNav }) => {
color: whiteColor,
},
};
const instanceLoading = useSelector((state) => state.instances.isLoading);

useEffect(() => {
setIsLoading(instanceLoading)
}, [instanceLoading])
Comment thread
jrmartin marked this conversation as resolved.
Outdated


useEffect(() => {
// For bulk loading, check if all instances are loaded using bulk count
Expand Down
Loading