mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
fix(core): fix too many subscription request (#6809)
This commit is contained in:
@@ -25,11 +25,17 @@ export const AISubscribe = ({ ...btnProps }: AISubscribeProps) => {
|
||||
|
||||
useEffect(() => {
|
||||
if (isOpenedExternalWindow) {
|
||||
// when the external window is opened, revalidate the subscription status every 3 seconds
|
||||
const timer = setInterval(() => {
|
||||
subscriptionService.subscription.revalidate();
|
||||
}, 3000);
|
||||
return () => clearInterval(timer);
|
||||
// when the external window is opened, revalidate the subscription when window get focus
|
||||
window.addEventListener(
|
||||
'focus',
|
||||
subscriptionService.subscription.revalidate
|
||||
);
|
||||
return () => {
|
||||
window.removeEventListener(
|
||||
'focus',
|
||||
subscriptionService.subscription.revalidate
|
||||
);
|
||||
};
|
||||
}
|
||||
return;
|
||||
}, [isOpenedExternalWindow, subscriptionService]);
|
||||
|
||||
@@ -235,11 +235,17 @@ const Upgrade = ({ recurring }: { recurring: SubscriptionRecurring }) => {
|
||||
|
||||
useEffect(() => {
|
||||
if (isOpenedExternalWindow) {
|
||||
// when the external window is opened, revalidate the subscription status every 3 seconds
|
||||
const timer = setInterval(() => {
|
||||
subscriptionService.subscription.revalidate();
|
||||
}, 1000);
|
||||
return () => clearInterval(timer);
|
||||
// when the external window is opened, revalidate the subscription when window get focus
|
||||
window.addEventListener(
|
||||
'focus',
|
||||
subscriptionService.subscription.revalidate
|
||||
);
|
||||
return () => {
|
||||
window.removeEventListener(
|
||||
'focus',
|
||||
subscriptionService.subscription.revalidate
|
||||
);
|
||||
};
|
||||
}
|
||||
return;
|
||||
}, [isOpenedExternalWindow, subscriptionService]);
|
||||
|
||||
Reference in New Issue
Block a user