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