Skip to content

Commit cb2c244

Browse files
committed
feat: simplify sponsor page messaging
1 parent b2e34f4 commit cb2c244

6 files changed

Lines changed: 196 additions & 524 deletions

File tree

src/renderer/components/SidebarNavigation.subscription.render.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ describe('subscription sidebar and shell wiring', () => {
2222
assert.match(sidebarSource, /labelKey: 'sidebar\.subscription'/);
2323
assert.match(sidebarSource, /distributionState\.winStoreMode/);
2424
assert.match(sidebarSource, /typeof window\.electronAPI\.subscription\?\.getSnapshot === 'function'/);
25-
assert.match(sidebarSource, /getSubscriptionBadgeLabel\(subscriptionSnapshot, t\)/);
25+
assert.doesNotMatch(sidebarSource, /selectSubscriptionSnapshot/);
26+
assert.doesNotMatch(sidebarSource, /getSubscriptionBadgeLabel/);
27+
assert.doesNotMatch(sidebarSource, /getSubscriptionBadgeVariant/);
28+
assert.doesNotMatch(sidebarSource, /item\.id === 'subscription'/);
2629
assert.match(appSource, /import SubscriptionPage from '\.\/components\/subscription\/SubscriptionPage';/);
2730
assert.match(appSource, /subscriptionFeatureEnabled && currentView === 'subscription' && <SubscriptionPage \/>/);
2831
assert.match(storeSource, /subscriptionFeatureEnabled \? \[store\.dispatch\(loadSubscriptionSnapshot\(\)\)\] : \[\]/);

src/renderer/components/SidebarNavigation.tsx

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ import {
1919
} from 'lucide-react';
2020
import { switchView } from '../store/slices/viewSlice';
2121
import type { RootState } from '../store';
22-
import { selectSubscriptionSnapshot } from '../store/slices/subscriptionSlice';
2322
import type { ViewType } from '../store/slices/viewSlice';
24-
import type { SubscriptionSnapshot } from '../../types/subscription.js';
25-
import { Badge } from './ui/badge';
2623
import { ThemeToggle } from './ui/theme-toggle';
2724
import { LanguageToggle } from './ui/language-toggle';
2825
import { Popover, PopoverContent, PopoverTrigger } from './ui/popover';
@@ -145,43 +142,6 @@ function getAboutEntryHint(entry: SidebarAboutEntry): string {
145142
return entry.detail;
146143
}
147144

148-
function getSubscriptionBadgeVariant(snapshot: SubscriptionSnapshot | null): 'default' | 'secondary' | 'destructive' | 'outline' {
149-
if (!snapshot) {
150-
return 'outline';
151-
}
152-
153-
if (snapshot.availability !== 'supported') {
154-
return 'destructive';
155-
}
156-
157-
if (snapshot.isStale) {
158-
return 'secondary';
159-
}
160-
161-
return snapshot.status === 'active' ? 'default' : 'outline';
162-
}
163-
164-
function getSubscriptionBadgeLabel(
165-
snapshot: SubscriptionSnapshot | null,
166-
t: (key: string) => string,
167-
): string {
168-
if (!snapshot) {
169-
return t('sidebar.subscriptionStatus.loading');
170-
}
171-
172-
if (snapshot.availability !== 'supported') {
173-
return t('sidebar.subscriptionStatus.unavailable');
174-
}
175-
176-
if (snapshot.isStale) {
177-
return t('sidebar.subscriptionStatus.stale');
178-
}
179-
180-
return snapshot.status === 'active'
181-
? t('sidebar.subscriptionStatus.active')
182-
: t('sidebar.subscriptionStatus.inactive');
183-
}
184-
185145
function AboutBrandLogo({ entry }: { entry: SidebarAboutEntry }) {
186146
const [imageFailed, setImageFailed] = useState(false);
187147
const domain = getAboutBrandDomain(entry);
@@ -213,7 +173,6 @@ export default function SidebarNavigation({ distributionState }: SidebarNavigati
213173
const { t, i18n } = useTranslation('common');
214174
const dispatch = useDispatch();
215175
const currentView = useSelector((state: RootState) => state.view.currentView);
216-
const subscriptionSnapshot = useSelector((state: RootState) => selectSubscriptionSnapshot(state));
217176
const isFusionMode = distributionState.fusionMode;
218177
const subscriptionFeatureEnabled = distributionState.winStoreMode
219178
&& typeof window.electronAPI.subscription?.getSnapshot === 'function';
@@ -569,15 +528,6 @@ export default function SidebarNavigation({ distributionState }: SidebarNavigati
569528
<span className="truncate font-medium text-sm whitespace-nowrap">
570529
{t(item.labelKey)}
571530
</span>
572-
573-
{item.id === 'subscription' ? (
574-
<Badge
575-
variant={getSubscriptionBadgeVariant(subscriptionSnapshot)}
576-
className="rounded-md px-1.5 py-0 text-[10px] uppercase tracking-[0.14em]"
577-
>
578-
{getSubscriptionBadgeLabel(subscriptionSnapshot, t)}
579-
</Badge>
580-
) : null}
581531
</motion.div>
582532
)}
583533
</AnimatePresence>

src/renderer/components/subscription/SubscriptionPage.render.test.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const pagePath = path.resolve(process.cwd(), 'src/renderer/components/subscripti
77
const slicePath = path.resolve(process.cwd(), 'src/renderer/store/slices/subscriptionSlice.ts');
88

99
describe('subscription workspace renderer', () => {
10-
it('renders loading, stale, unsupported, entitlement, and diagnostics states with thunk-driven actions', async () => {
10+
it('renders a centered subscription card with thunk-driven actions and sponsor messaging', async () => {
1111
const [pageSource, sliceSource] = await Promise.all([
1212
fs.readFile(pagePath, 'utf8'),
1313
fs.readFile(slicePath, 'utf8'),
@@ -19,12 +19,16 @@ describe('subscription workspace renderer', () => {
1919
assert.match(pageSource, /dispatch\(refreshSubscriptionSnapshot\(\)\)/);
2020
assert.match(pageSource, /dispatch\(purchaseSubscription\(\)\)/);
2121
assert.match(pageSource, /subscription\.purchaseOutcome\./);
22-
assert.match(pageSource, /subscriptionEntitlementNames\.map\(\(entitlement\) => \{/);
23-
assert.match(pageSource, /subscription\.entitlements\.names\.\$\{entitlement\}/);
24-
assert.match(pageSource, /subscription\.entitlements\.details\.\$\{entitlement\}/);
25-
assert.match(pageSource, /subscription\.diagnostics\.title/);
26-
assert.match(pageSource, /selectHasSubscriptionEntitlement\(state, 'sponsorBadge'\)/);
27-
assert.match(pageSource, /selectHasSubscriptionEntitlement\(state, 'premiumFeatureGate'\)/);
22+
assert.match(pageSource, /mx-auto max-w-2xl overflow-hidden rounded-\[36px\]/);
23+
assert.match(pageSource, /subscription\.message\.ongoingTitle/);
24+
assert.match(pageSource, /subscription\.message\.perksTitle/);
25+
assert.match(pageSource, /subscription\.message\.unlockNoticeTitle/);
26+
assert.match(pageSource, /subscription\.message\.unlockNoticeDescription/);
27+
assert.match(pageSource, /subscription\.message\.activeThanks/);
28+
assert.match(pageSource, /subscription\.message\.inactivePrompt/);
29+
assert.doesNotMatch(pageSource, /subscriptionEntitlementNames\.map\(\(entitlement\) => \{/);
30+
assert.doesNotMatch(pageSource, /selectHasSubscriptionEntitlement/);
31+
assert.doesNotMatch(pageSource, /subscription\.snapshot\.fields\.lastCheckedAt/);
2832
assert.match(sliceSource, /createAsyncThunk\(/);
2933
assert.match(sliceSource, /'subscription\/loadSnapshot'/);
3034
assert.match(sliceSource, /'subscription\/refreshSnapshot'/);

0 commit comments

Comments
 (0)