Rework licensing flows to be more friendly

This commit is contained in:
Gregory Schier
2025-09-29 15:40:15 -07:00
parent 7262eccac5
commit 6c79c1ef3f
15 changed files with 133 additions and 79 deletions

View File

@@ -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');
}}
>