From 73185e7cbc39f7dbeb36473a22692625d08de32f Mon Sep 17 00:00:00 2001 From: Zamitto <167933696+zamitto@users.noreply.github.com> Date: Tue, 22 Oct 2024 22:33:23 -0300 Subject: [PATCH] fix: small adjustment --- src/main/services/hydra-api.ts | 4 ++-- src/renderer/src/hooks/use-user-details.ts | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/services/hydra-api.ts b/src/main/services/hydra-api.ts index 41d76408..e3e772e8 100644 --- a/src/main/services/hydra-api.ts +++ b/src/main/services/hydra-api.ts @@ -44,7 +44,7 @@ export class HydraApi { return this.userAuth.authToken !== ""; } - private static hasCloudSubscription() { + private static hasActiveSubscription() { return ( this.userAuth.subscription?.expiresAt && this.userAuth.subscription.expiresAt > new Date() @@ -279,7 +279,7 @@ export class HydraApi { } if (needsSubscription) { - if (!(await this.hasCloudSubscription())) { + if (!(await this.hasActiveSubscription())) { throw new SubscriptionRequiredError(); } } diff --git a/src/renderer/src/hooks/use-user-details.ts b/src/renderer/src/hooks/use-user-details.ts index a0dfa7ff..ab4408cc 100644 --- a/src/renderer/src/hooks/use-user-details.ts +++ b/src/renderer/src/hooks/use-user-details.ts @@ -128,12 +128,8 @@ export function useUserDetails() { const unblockUser = (userId: string) => window.electron.unblockUser(userId); const hasActiveSubscription = useMemo(() => { - if (!userDetails?.subscription?.plan) { - return false; - } - return ( - userDetails.subscription.expiresAt && + userDetails?.subscription?.expiresAt && new Date(userDetails.subscription.expiresAt) > new Date() ); }, [userDetails]);