Skip to content

Commit

Permalink
move null check
Browse files Browse the repository at this point in the history
  • Loading branch information
davemarco committed Oct 1, 2024
1 parent 6f43e7f commit d266ce7
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions new-log-viewer/src/contexts/StateContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,9 @@ const getPageNumCursor = (
* @param cursor
*/
const loadPageByCursor = (
worker: Nullable<Worker>,
worker: Worker,
cursor: CursorType,
) => {
if (null === worker) {
console.error("Unexpected null worker");

return;
}

workerPostReq(worker, WORKER_REQ_CODE.LOAD_PAGE, {
cursor: cursor,
decoderOptions: getConfig(CONFIG_KEY.DECODER_OPTIONS),
Expand Down Expand Up @@ -291,6 +285,11 @@ const StateContextProvider = ({children}: StateContextProviderProps) => {


const loadPageByAction = useCallback((navAction: NavigationAction) => {
if (null === mainWorkerRef.current) {
console.error("Unexpected null mainWorkerRef.current");

return;
}
const cursor = getPageNumCursor(navAction, pageNumRef.current, numPagesRef.current);
if (null === cursor) {
console.error(`Error with nav action ${navAction.code}.`);
Expand All @@ -316,6 +315,12 @@ const StateContextProvider = ({children}: StateContextProviderProps) => {

// On `logEventNum` update, clamp it then switch page if necessary or simply update the URL.
useEffect(() => {
if (null === mainWorkerRef.current) {
console.error("Unexpected null mainWorkerRef.current");

return;
}

Check failure on line 323 in new-log-viewer/src/contexts/StateContextProvider.tsx

View workflow job for this annotation

GitHub Actions / lint-check

Trailing spaces not allowed
if (URL_HASH_PARAMS_DEFAULT.logEventNum === logEventNum) {
return;
}
Expand Down

0 comments on commit d266ce7

Please sign in to comment.