mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-22 16:48:30 +02:00
Rework licensing flows to be more friendly
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import type { LicenseCheckStatus } from '@yaakapp-internal/license';
|
||||
import { useLicense } from '@yaakapp-internal/license';
|
||||
import { settingsAtom } from '@yaakapp-internal/models';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import type { ReactNode } from 'react';
|
||||
import { openSettings } from '../commands/openSettings';
|
||||
import { useLicenseConfirmation } from '../hooks/useLicenseConfirmation';
|
||||
import { appInfo } from '../lib/appInfo';
|
||||
import { BadgeButton } from './core/BadgeButton';
|
||||
import type { ButtonProps } from './core/Button';
|
||||
@@ -19,7 +20,7 @@ const details: Record<
|
||||
|
||||
export function LicenseBadge() {
|
||||
const { check } = useLicense();
|
||||
const [licenseDetails, setLicenseDetails] = useLicenseConfirmation();
|
||||
const settings = useAtomValue(settingsAtom);
|
||||
|
||||
if (appInfo.isDev) {
|
||||
return null;
|
||||
@@ -32,17 +33,17 @@ export function LicenseBadge() {
|
||||
}
|
||||
|
||||
// Hasn't loaded yet
|
||||
if (licenseDetails == null || check.data == null) {
|
||||
if (check.data == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// User has confirmed they are using Yaak for personal use only, so hide badge
|
||||
if (licenseDetails.confirmedPersonalUse) {
|
||||
// Dismissed license badge
|
||||
if (settings.hideLicenseBadge) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// User is trialing but has already seen the message, so hide badge
|
||||
if (check.data.type === 'trialing' && licenseDetails.hasDismissedTrial) {
|
||||
if (check.data.type === 'trialing') {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -55,12 +56,6 @@ export function LicenseBadge() {
|
||||
<BadgeButton
|
||||
color={detail.color}
|
||||
onClick={async () => {
|
||||
if (check.data.type === 'trialing') {
|
||||
await setLicenseDetails((v) => ({
|
||||
...v,
|
||||
hasDismissedTrial: true,
|
||||
}));
|
||||
}
|
||||
openSettings.mutate('license');
|
||||
}}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user