diff --git a/new-log-viewer/src/contexts/StateContextProvider.tsx b/new-log-viewer/src/contexts/StateContextProvider.tsx index 63dba7ac..55f165c2 100644 --- a/new-log-viewer/src/contexts/StateContextProvider.tsx +++ b/new-log-viewer/src/contexts/StateContextProvider.tsx @@ -209,8 +209,8 @@ const StateContextProvider = ({children}: StateContextProviderProps) => { const [fileName, setFileName] = useState(STATE_DEFAULT.fileName); const [logData, setLogData] = useState(STATE_DEFAULT.logData); const [numEvents, setNumEvents] = useState(STATE_DEFAULT.numEvents); - const [pageNum, setPageNum] = useState(STATE_DEFAULT.pageNum); const [numPages, setNumPages] = useState(STATE_DEFAULT.numPages); + const [pageNum, setPageNum] = useState(STATE_DEFAULT.pageNum); const beginLineNumToLogEventNumRef = useRef(STATE_DEFAULT.beginLineNumToLogEventNum); const [exportProgress, setExportProgress] = @@ -218,8 +218,8 @@ const StateContextProvider = ({children}: StateContextProviderProps) => { // Refs const logEventNumRef = useRef(logEventNum); - const numPagesRef = useRef(pageNum); - const pageNumRef = useRef(numPages); + const numPagesRef = useRef(numPages); + const pageNumRef = useRef(pageNum); const logExportManagerRef = useRef(null); const mainWorkerRef = useRef(null); @@ -245,8 +245,8 @@ const StateContextProvider = ({children}: StateContextProviderProps) => { break; case WORKER_RESP_CODE.PAGE_DATA: { setLogData(args.logs); - setPageNum(args.pageNum); setNumPages(args.numPages); + setPageNum(args.pageNum); beginLineNumToLogEventNumRef.current = args.beginLineNumToLogEventNum; updateWindowUrlHashParams({ logEventNum: args.logEventNum, diff --git a/new-log-viewer/src/services/LogFileManager/utils.ts b/new-log-viewer/src/services/LogFileManager/utils.ts index 5e601345..a40ceb97 100644 --- a/new-log-viewer/src/services/LogFileManager/utils.ts +++ b/new-log-viewer/src/services/LogFileManager/utils.ts @@ -131,12 +131,13 @@ const getMatchingLogEventNum = ( return 0; } - return null !== filteredLogEventMap ? - - // Explicit cast since typescript thinks `filteredLogEventMap[matchingIdx]` can be - // undefined, but it can't since filteredLogEventMap has a length >= 1. - (filteredLogEventMap[matchingIdx] as number) + 1 : - matchingIdx + 1; + // Explicit cast since typescript thinks `filteredLogEventMap[matchingIdx]` can be + // undefined, but it can't since filteredLogEventMap has a length >= 1. + return 1 + ( + null !== filteredLogEventMap ? + (filteredLogEventMap[matchingIdx] as number) : + matchingIdx + ); }; @@ -150,8 +151,8 @@ const getMatchingLogEventNum = ( */ const getNewNumPages = ( numEvents: number, - pageSize: number, filteredLogEventMap: FilteredLogEventMap, + pageSize: number, ): number => { const numActiveEvents: number = filteredLogEventMap ? filteredLogEventMap.length :