From 396f0d64fed7897464b6c8ee1cde84f2fab81435 Mon Sep 17 00:00:00 2001 From: Vlad Date: Mon, 24 Jun 2024 17:35:16 -0400 Subject: [PATCH] Fix random route popping up on scrolls (#523) * Fix random route on scroll. * Linting error. --------- Co-authored-by: Shane Smiskol --- src/reducers/globalState.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/reducers/globalState.js b/src/reducers/globalState.js index b63767c6..c2d3a308 100644 --- a/src/reducers/globalState.js +++ b/src/reducers/globalState.js @@ -292,6 +292,11 @@ export default function reducer(_state, action) { if (!state.zoom || !action.start || !action.end || action.start < state.zoom.start || action.end > state.zoom.end) { state.files = null; } + + if (!action.log_id) { + state.segmentRange = null; + } + const r = state.routes?.find((route) => route.log_id === action.log_id); if (action.log_id && r) { state.currentRoute = r; @@ -416,12 +421,13 @@ export default function reducer(_state, action) { case Types.ACTION_UPDATE_SEGMENT_RANGE: { if (!action.log_id) { state.segmentRange = null; + } else { + state.segmentRange = { + log_id: action.log_id, + start: action.start, + end: action.end, + }; } - state.segmentRange = { - log_id: action.log_id, - start: action.start, - end: action.end, - }; break; } default: