Skip to content

[UIEUS-512] Fix jobs page not fetching fresh data on navigation#620

Open
alb3rtino wants to merge 3 commits intomasterfrom
UIEUS-512
Open

[UIEUS-512] Fix jobs page not fetching fresh data on navigation#620
alb3rtino wants to merge 3 commits intomasterfrom
UIEUS-512

Conversation

@alb3rtino
Copy link
Copy Markdown
Contributor

@alb3rtino alb3rtino commented Mar 12, 2026

https://folio-org.atlassian.net/browse/UIEUS-512

Purpose

When users navigate to the jobs page (/eusage/jobs), stale data from the initial module load is displayed because the timestamp used in the query was set once at module evaluation time. Users had to manually refresh to see current job information.

Approach

  • Replaced the static module-level timestamp variable with a useEffect hook in JobsViewRoute that calls mutator.timestamp.replace(Date.now()) on each mount, ensuring a fresh fetch on every navigation
  • Guarded onNeedMoreData in JobsView to only call source.fetchMore() when loaded records are fewer than total available records
  • Added a test verifying that the timestamp mutator is called on mount

@alb3rtino alb3rtino requested a review from a team as a code owner March 12, 2026 19:12
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 12, 2026

Jest Unit Test Results

197 tests  +1   197 ✅ +1   2m 37s ⏱️ ±0s
 39 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 03d8e78. ± Comparison against base commit fef97e9.

♻️ This comment has been updated with latest results.

Copy link
Copy Markdown
Contributor

@elsenhans elsenhans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good!
Just seems like on every mount, two fetches are triggered now: One with the timestamp from initialValue, immediately followed by a second with the timestamp from useEffect.

@sonarqubecloud
Copy link
Copy Markdown

@alb3rtino alb3rtino requested a review from elsenhans March 25, 2026 21:33
timestamp: {
initialValue: timestamp,
},
timestamp: { initialValue: Date.now() },
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider initializing with initialValue: null since the value will be overwritten by the useEffect anyway.

}}
onNeedMoreData={() => {
source.fetchMore(30);
if (source.totalCount() > source.records().length) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a test for the onNeedMoreData guard to verify that fetchMore is only called when totalCount() > records().length.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants