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

fix(js): Bypass cache during novu.notifications.list() #6690

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

SokratisVidros
Copy link
Contributor

What changed? Why was the change needed?

Introduce novu.notifications.list({ useCache: true | false }) option to always fetch the latest notifications and bypass the cache. This should give the ability to build an Inbox UI that auto-refreshes when a new notification is available.

The useCache option of the list function defaults to true.

Copy link

netlify bot commented Oct 14, 2024

Deploy Preview for novu-stg-vite-dashboard-poc ready!

Name Link
🔨 Latest commit 9d9de09
🔍 Latest deploy log https://app.netlify.com/sites/novu-stg-vite-dashboard-poc/deploys/670fb68e46cd4d000895a817
😎 Deploy Preview https://deploy-preview-6690--novu-stg-vite-dashboard-poc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

return this.callWithSession(async () => {
const args = { limit, ...restOptions };
try {
let data: ListNotificationsResponse | undefined = this.#useCache ? this.cache.getAll(args) : undefined;
let data: ListNotificationsResponse | undefined =
this.#useCache || useCache ? this.cache.getAll(args) : undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

@SokratisVidros, if I have set useCache: true in the options to the Novu class, then this function option useCache won't help with the override because the first part of or will be satisfied. Only when the options on the Novu class are use cache: false it will control it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤦 good catch.It should be the other way around.

Introduce novu.notifications.list({ useCache: false }) option to always fetch the latest notifications and bypass the cache.
Copy link

pkg-pr-new bot commented Oct 16, 2024

Open in Stackblitz

pnpm add https://pkg.pr.new/novuhq/novu/@novu/js@6690
pnpm add https://pkg.pr.new/novuhq/novu/@novu/nextjs@6690
pnpm add https://pkg.pr.new/novuhq/novu/@novu/react@6690
pnpm add https://pkg.pr.new/novuhq/novu/@novu/react-native@6690

commit: 9d9de09

@SokratisVidros SokratisVidros merged commit 7fb1570 into next Oct 16, 2024
31 checks passed
@SokratisVidros SokratisVidros deleted the cache_false branch October 16, 2024 13:06
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.

2 participants