mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-28 13:21:02 +00:00
Merge pull request #1510 from hydralauncher/feat/simplify-subscription-expires-at
feat: simplify subscription expires at
This commit is contained in:
@@ -13,7 +13,6 @@ import { logger } from "./logger";
|
|||||||
import { WindowManager } from "./window-manager";
|
import { WindowManager } from "./window-manager";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { Ludusavi } from "./ludusavi";
|
import { Ludusavi } from "./ludusavi";
|
||||||
import { isFuture, isToday } from "date-fns";
|
|
||||||
import { SubscriptionRequiredError } from "@shared";
|
import { SubscriptionRequiredError } from "@shared";
|
||||||
|
|
||||||
export class CloudSync {
|
export class CloudSync {
|
||||||
@@ -54,8 +53,8 @@ export class CloudSync {
|
|||||||
const hasActiveSubscription = await db
|
const hasActiveSubscription = await db
|
||||||
.get<string, User>(levelKeys.user, { valueEncoding: "json" })
|
.get<string, User>(levelKeys.user, { valueEncoding: "json" })
|
||||||
.then((user) => {
|
.then((user) => {
|
||||||
const expiresAt = user?.subscription?.expiresAt;
|
const expiresAt = new Date(user?.subscription?.expiresAt ?? 0);
|
||||||
return expiresAt && (isFuture(expiresAt) || isToday(expiresAt));
|
return expiresAt > new Date();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!hasActiveSubscription) {
|
if (!hasActiveSubscription) {
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import { UserNotLoggedInError, SubscriptionRequiredError } from "@shared";
|
|||||||
import { omit } from "lodash-es";
|
import { omit } from "lodash-es";
|
||||||
import { appVersion } from "@main/constants";
|
import { appVersion } from "@main/constants";
|
||||||
import { getUserData } from "./user/get-user-data";
|
import { getUserData } from "./user/get-user-data";
|
||||||
import { isFuture, isToday } from "date-fns";
|
|
||||||
import { db } from "@main/level";
|
import { db } from "@main/level";
|
||||||
import { levelKeys } from "@main/level/sublevels";
|
import { levelKeys } from "@main/level/sublevels";
|
||||||
import type { Auth, User } from "@types";
|
import type { Auth, User } from "@types";
|
||||||
@@ -47,8 +46,8 @@ export class HydraApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static hasActiveSubscription() {
|
private static hasActiveSubscription() {
|
||||||
const expiresAt = this.userAuth.subscription?.expiresAt;
|
const expiresAt = new Date(this.userAuth.subscription?.expiresAt ?? 0);
|
||||||
return expiresAt && (isFuture(expiresAt) || isToday(expiresAt));
|
return expiresAt > new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
static async handleExternalAuth(uri: string) {
|
static async handleExternalAuth(uri: string) {
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import type {
|
|||||||
} from "@types";
|
} from "@types";
|
||||||
import * as Sentry from "@sentry/react";
|
import * as Sentry from "@sentry/react";
|
||||||
import { UserFriendModalTab } from "@renderer/pages/shared-modals/user-friend-modal";
|
import { UserFriendModalTab } from "@renderer/pages/shared-modals/user-friend-modal";
|
||||||
import { isFuture, isToday } from "date-fns";
|
|
||||||
|
|
||||||
export function useUserDetails() {
|
export function useUserDetails() {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
@@ -146,8 +145,8 @@ export function useUserDetails() {
|
|||||||
const unblockUser = (userId: string) => window.electron.unblockUser(userId);
|
const unblockUser = (userId: string) => window.electron.unblockUser(userId);
|
||||||
|
|
||||||
const hasActiveSubscription = useMemo(() => {
|
const hasActiveSubscription = useMemo(() => {
|
||||||
const expiresAt = userDetails?.subscription?.expiresAt;
|
const expiresAt = new Date(userDetails?.subscription?.expiresAt ?? 0);
|
||||||
return expiresAt && (isFuture(expiresAt) || isToday(expiresAt));
|
return expiresAt > new Date();
|
||||||
}, [userDetails]);
|
}, [userDetails]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
@use "../../scss/globals.scss";
|
@use "../../scss/globals.scss";
|
||||||
|
@use "sass:color";
|
||||||
|
|
||||||
.theme-editor {
|
.theme-editor {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -58,7 +59,10 @@
|
|||||||
gap: 8px;
|
gap: 8px;
|
||||||
|
|
||||||
.active {
|
.active {
|
||||||
background-color: darken(globals.$dark-background-color, 2%);
|
background-color: color.adjust(
|
||||||
|
globals.$dark-background-color,
|
||||||
|
$lightness: -2%
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user