From 1e4cbf3bb120cc4fb0cb4ed286dc39bbea8b29fa Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Thu, 5 May 2022 15:03:09 -0700 Subject: [PATCH] Set logfile isFetching initial state to true Setting the logfile isFetching initial state to true is more accurate to reality as when the logfile object is first insantiated it has not been fetched and is going to be fetched. This is important to ensure our useEffect() callbacks file and apply at the right times otherwise they will update values too early, fire, then not fire again when the fetching is complete. If they fire before fetching is complete then they do not function. Change-Id: Ic8cd2e4ab2d2d7fd5f74ff6862f719c0aaa756dc --- web/src/containers/logfile/LogFile.jsx | 5 +++++ web/src/reducers/initialState.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/web/src/containers/logfile/LogFile.jsx b/web/src/containers/logfile/LogFile.jsx index f8b198450e..7184646bd0 100644 --- a/web/src/containers/logfile/LogFile.jsx +++ b/web/src/containers/logfile/LogFile.jsx @@ -59,6 +59,11 @@ export default function LogFile({ // Only highlight the lines if the log is present (otherwise it doesn't make // sense). Although, scrolling to the selected section only works once the // necessary log lines are part of the DOM tree. + // Additionally note that if we set highlightStart before the page content + // is available then the window scrolling won't match any lines and we won't + // scroll. Then when we try to set highlightStart after page content is loaded + // the value isn't different than what is set previously preventing the + // scroll event from firing. if (!isFetching) { // Get the line numbers to highlight from the URL and directly cast them to // a number. The substring(1) removes the '#' character. diff --git a/web/src/reducers/initialState.js b/web/src/reducers/initialState.js index ce74956e9e..d2e3060328 100644 --- a/web/src/reducers/initialState.js +++ b/web/src/reducers/initialState.js @@ -23,7 +23,7 @@ export default { logfile: { // Store files by buildId->filename->content files: {}, - isFetching: false, + isFetching: true, url: null, }, auth: {},