Skip to content

Commit 5b5c734

Browse files
(tauri) Fix windows st include/exclude logic (#5029)
* - Reverse the included/excluded logic - Allow include/exclude when st is disabled * Use accountSummary.is-subscription-active in Account settings
1 parent 8fc2988 commit 5b5c734

5 files changed

Lines changed: 28 additions & 21 deletions

File tree

nym-vpn-app/src/screens/settings/account/AccountDescription.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export function AccountDescription() {
2323
t,
2424
accountSyncing,
2525
accountState,
26+
accountSummary,
2627
);
2728

2829
const status = useMemo(
@@ -34,15 +35,19 @@ export function AccountDescription() {
3435
return (
3536
<span
3637
className={clsx(
37-
getAccountDescriptionColor(accountSyncing, accountState),
38+
getAccountDescriptionColor(
39+
accountSyncing,
40+
accountState,
41+
accountSummary,
42+
),
3843
)}
3944
>
4045
{accountStateDescription}
4146
</span>
4247
);
4348
}
4449

45-
if (!accountSummary) {
50+
if (!accountSummary?.['subscription-valid-until']) {
4651
return null;
4752
}
4853

nym-vpn-app/src/screens/settings/account/account-status/AccountStatus.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ export function AccountStatus() {
1414
const needsSubscription = useMemo(
1515
() =>
1616
accountState === 'no-subscription' ||
17-
accountState === 'status-not-active',
18-
[accountState],
17+
accountState === 'status-not-active' ||
18+
!accountSummary?.['is-subscription-active'],
19+
[accountState, accountSummary],
1920
);
2021

2122
if (!accountState || accountState === 'error' || accountState === 'offline') {

nym-vpn-app/src/screens/settings/account/utils.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { AccountState, TAccountSummary } from '../../../types';
55
export const getAccountDescriptionColor = (
66
accountSyncing: boolean,
77
state?: AccountState | null,
8+
accountSummary?: TAccountSummary | null,
89
) => {
910
if (accountSyncing) {
1011
return 'text-iron dark:text-bombay';
@@ -20,13 +21,17 @@ export const getAccountDescriptionColor = (
2021
if (state === 'offline' || state === 'status-not-active') {
2122
return 'text-cheddar dark:text-king-nacho ';
2223
}
24+
if (!accountSummary?.['is-subscription-active']) {
25+
return 'text-aphrodisiac';
26+
}
2327
return 'text-iron dark:text-bombay';
2428
};
2529

2630
export const getAccountStateDescription = (
2731
t: TFunction<'settings', undefined>,
2832
accountSyncing: boolean,
2933
state?: AccountState | null,
34+
accountSummary?: TAccountSummary | null,
3035
) => {
3136
if (accountSyncing) {
3237
return t('account.syncing');
@@ -51,9 +56,14 @@ export const getAccountStateDescription = (
5156
return t('account.offline', { ns: 'errors' });
5257
case 'error':
5358
return t('account.internal', { ns: 'errors' });
54-
default:
55-
return null;
5659
}
60+
61+
if (!accountSummary?.['is-subscription-active']) {
62+
return t('account.no-plan');
63+
}
64+
65+
// Global default
66+
return null;
5767
};
5868

5969
export const getAccountStatus = (accountSummary?: TAccountSummary | null) => {

nym-vpn-app/src/screens/settings/split-tunneling/AppItem.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@ export type AppEntry = App & {
99

1010
type AppItemProps = {
1111
app: AppEntry;
12-
enabled: boolean;
1312
onStateChange: (
1413
app: AppEntry,
1514
state: 'excluded' | 'included',
1615
) => Promise<void>;
1716
};
1817

19-
function AppItem({ app, enabled, onStateChange }: AppItemProps) {
18+
function AppItem({ app, onStateChange }: AppItemProps) {
2019
return (
2120
<div className="flex items-center gap-3 px-4 py-3 bg-white dark:bg-charcoal">
2221
<div className="w-7 h-7 flex items-center justify-center">
@@ -40,28 +39,24 @@ function AppItem({ app, enabled, onStateChange }: AppItemProps) {
4039
<button
4140
className={clsx(
4241
'px-2 h-full w-full flex items-center justify-center cursor-default transition-noborder border-r border-r-iron dark:border-r-bombay rounded-l-lg',
43-
app.state === 'excluded'
42+
app.state === 'included'
4443
? 'bg-aphrodisiac/20 text-aphrodisiac'
4544
: 'text-iron dark:text-bombay',
46-
!enabled && 'opacity-50 cursor-not-allowed',
4745
)}
48-
onClick={() => onStateChange(app, 'excluded')}
46+
onClick={() => onStateChange(app, 'included')}
4947
aria-label={`Exclude ${app.name} from VPN`}
50-
disabled={!enabled}
5148
>
5249
<MsIcon icon="block" className="text-base" />
5350
</button>
5451
<button
5552
className={clsx(
5653
'px-2 h-full w-full flex items-center justify-center cursor-default transition-noborder rounded-r-lg',
57-
app.state === 'included'
54+
app.state === 'excluded'
5855
? 'bg-malachite-moss/15 dark:bg-malachite/15 text-malachite-moss dark:text-malachite'
5956
: 'text-iron dark:text-bombay',
60-
!enabled && 'opacity-50 cursor-not-allowed',
6157
)}
62-
onClick={() => onStateChange(app, 'included')}
58+
onClick={() => onStateChange(app, 'excluded')}
6359
aria-label={`Include ${app.name} in VPN`}
64-
disabled={!enabled}
6560
>
6661
<MsIcon icon="shield" className="text-base" />
6762
</button>

nym-vpn-app/src/screens/settings/split-tunneling/SplitTunneling.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,7 @@ function SplitTunneling() {
104104
{/* Apps in this section */}
105105
{groupedApps[letter].map((app, i) => (
106106
<div key={app.name}>
107-
<AppItem
108-
app={app}
109-
enabled={enabled}
110-
onStateChange={handleStateChange}
111-
/>
107+
<AppItem app={app} onStateChange={handleStateChange} />
112108
{i < groupedApps[letter].length - 1 && (
113109
<div className="mx-4 h-px bg-mercury/60 dark:bg-white/5" />
114110
)}

0 commit comments

Comments
 (0)