feat: simplify subscription expires at comparison

This commit is contained in:
Zamitto
2025-03-10 21:23:26 -03:00
parent f12784b6e7
commit 6626368613
3 changed files with 6 additions and 9 deletions

View File

@@ -13,7 +13,6 @@ import { logger } from "./logger";
import { WindowManager } from "./window-manager";
import axios from "axios";
import { Ludusavi } from "./ludusavi";
import { isFuture, isToday } from "date-fns";
import { SubscriptionRequiredError } from "@shared";
export class CloudSync {
@@ -54,8 +53,8 @@ export class CloudSync {
const hasActiveSubscription = await db
.get<string, User>(levelKeys.user, { valueEncoding: "json" })
.then((user) => {
const expiresAt = user?.subscription?.expiresAt;
return expiresAt && (isFuture(expiresAt) || isToday(expiresAt));
const expiresAt = new Date(user?.subscription?.expiresAt ?? 0);
return expiresAt > new Date();
});
if (!hasActiveSubscription) {