updates
This commit is contained in:
@@ -15,6 +15,7 @@ import { OpenToast } from 'components/nearle_components/OpenToast';
|
||||
const ActiveSection = ({
|
||||
visibleRiders,
|
||||
riders,
|
||||
resetKey,
|
||||
focusedStop,
|
||||
handleRiderFocus,
|
||||
setFocusedStop,
|
||||
@@ -35,6 +36,14 @@ const ActiveSection = ({
|
||||
|
||||
// Toast notifications: detect status transitions across renders
|
||||
const prevStatusMapRef = useRef(null);
|
||||
// Tracks which batch/date/location the baseline above belongs to. When it
|
||||
// changes (e.g. operator switches Morning Batch → Afternoon Batch) the
|
||||
// whole order set is replaced wholesale — that is a view switch, not a
|
||||
// stream of real status transitions, so we must reseed the baseline
|
||||
// silently instead of diffing against the old batch's orders (which would
|
||||
// otherwise treat every order in the new batch as "brand-new and already
|
||||
// active" and re-fire the delivering/reached toasts for all of them).
|
||||
const prevResetKeyRef = useRef(resetKey);
|
||||
|
||||
useEffect(() => {
|
||||
const currentMap = {};
|
||||
@@ -48,8 +57,9 @@ const ActiveSection = ({
|
||||
});
|
||||
});
|
||||
|
||||
const viewSwitched = prevResetKeyRef.current !== resetKey;
|
||||
const prev = prevStatusMapRef.current;
|
||||
if (prev !== null) {
|
||||
if (prev !== null && !viewSwitched) {
|
||||
Object.entries(currentMap).forEach(([oid, cur]) => {
|
||||
const old = prev[oid];
|
||||
if (!old) {
|
||||
@@ -71,7 +81,8 @@ const ActiveSection = ({
|
||||
}
|
||||
|
||||
prevStatusMapRef.current = currentMap;
|
||||
}, [visibleRiders]);
|
||||
prevResetKeyRef.current = resetKey;
|
||||
}, [visibleRiders, resetKey]);
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user