Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat) O3-4277: Enable app-specific SWRConfig #1253

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Twiineenock
Copy link
Contributor

@Twiineenock Twiineenock commented Dec 30, 2024

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. Ensure your PR title includes a conventional commit label (such as feat, fix, or chore, among others). See existing PR titles for inspiration.

For changes to apps

If applicable

  • My work includes tests or is validated by existing tests.
  • I have updated the esm-framework mock to reflect any API changes I have made.

Summary

Description

Work in this PR allows app-specific SWR configurations for example the service queues and ward apps, ensuring their data refresh rates align with their real-time requirements.

Background

Both the service queues and ward apps are used to display near real-time dashboards for OPD/IPD workflows. A recent global configuration change in the SWR library increased the default data cache time to 30 minutes. While this change optimizes performance for many apps, it is not suitable for apps requiring more frequent updates.

Screenshots

Related Issue

https://openmrs.atlassian.net/browse/O3-4277

Other

@Twiineenock
Copy link
Contributor Author

CC
@chibongho , @brandones, @denniskigen

Copy link
Contributor

@chibongho chibongho left a comment

Choose a reason for hiding this comment

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

Thanks @Twiineenock . I think we should be able to have app-specific SWRConfig without changes to core. I'm thinking of just wrapping the root component in root.comonent.tsx (in the ward app and the service queues app) with <SWRConfig>.

Copy link
Collaborator

@brandones brandones left a comment

Choose a reason for hiding this comment

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

I support this change. Doing it this way has two advantages:

  1. We can merge custom SWR config options with our application default options
  2. We avoid creating extra nested SWRConfig contexts

Maybe @ibacher or @denniskigen can weigh in, since @chibongho and I are at odds here?

@denniskigen denniskigen requested a review from ibacher January 9, 2025 19:33
@@ -31,6 +31,7 @@ export interface ComponentDecoratorOptions {
featureName: string;
disableTranslations?: boolean;
strictMode?: boolean;
swrConfig?: Partial<typeof defaultSwrConfig>;
Copy link
Member

Choose a reason for hiding this comment

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

This should really be Partial<Omit<SWRConfig, 'fetcher'>>, I think, or something similar.

Comment on lines 55 to 56
const opts = Object.assign({}, defaultOpts, userOpts);
const opts = { ...defaultOpts, ...userOpts };
Copy link
Member

Choose a reason for hiding this comment

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

Can we remove this non-functional change?

@ibacher ibacher dismissed chibongho’s stale review January 13, 2025 20:46

No specific changes requested

@ibacher
Copy link
Member

ibacher commented Jan 13, 2025

My own vote here is that we merge this or something like it in. I don't see any downsides to it and it does make it possible for app-specific default configurations to be applied in a relatively low-effort way. I don't think there's any reason that we can't just support both this and adding a nested SWRConfig, if someone feels like doing so.

@Twiineenock Twiineenock force-pushed the feat/enable-app-specific-SWRConfig branch from 2c2970f to 295e06e Compare January 14, 2025 08:49
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.

4 participants