Skip to content

Commit 155ed1d

Browse files
committed
Fix disconnecting UI and connecting toggle
1 parent 2118c4d commit 155ed1d

File tree

4 files changed

+21
-13
lines changed

4 files changed

+21
-13
lines changed

apple/client/StatusItem/ObscuraToggle.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ struct ObscuraToggle: View {
4848
self.toggleLabel = ToggleLabels.connecting
4949
do {
5050
try await self.startupModel.appState?.enableTunnel(TunnelArgs())
51-
self.isToggled = true
52-
self.toggleLabel = ToggleLabels.connected
5351
} catch {
5452
logger.error("Failed to connect from status menu \(error, privacy: .public)")
5553
self.toggleLabel = ToggleLabels.notConnected

obscura-ui/src/App.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,15 @@ export default function () {
235235
if (appStatus !== null) handleNewStatus(appStatus);
236236
}, [appStatus]);
237237

238+
useEffect(() => {
239+
if (osStatus !== null) {
240+
const { osVpnStatus } = osStatus;
241+
if (osVpnStatus === 'disconnecting') {
242+
setConnectionInProgress(ConnectionInProgress.Disconnecting);
243+
}
244+
}
245+
}, [osStatus]);
246+
238247
function resetState() {
239248
// Useful for runtime rendering exceptions
240249
if (vpnConnected) toggleVpnConnection();

obscura-ui/src/views/ConnectionView.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ export default function Connection() {
6565
const accountHasExpired = accountInfo !== null && accountIsExpired(accountInfo);
6666

6767
const getTitle = () => {
68-
if (vpnConnected) return t('connectedToObscura');
6968
if (accountHasExpired) return t('account-Expired');
7069
if (connectionTransition) {
7170
switch (connectionInProgress) {
@@ -78,16 +77,17 @@ export default function Connection() {
7877
return t('Disconnecting');
7978
}
8079
}
80+
if (vpnConnected) return t('connectedToObscura');
8181
if (!internetAvailable) return t('disconnected');
8282
if (accountInfo === null) return t('validatingAccount')
8383
return t('notConnected');
8484
}
8585

8686
const Subtitle = () => {
87-
if (vpnConnected) return t('enjoyObscura');
87+
if (vpnConnected && !connectionTransition) return t('enjoyObscura');
8888
if (accountHasExpired) return t('continueUsingObscura');
89-
if (!internetAvailable) return t('connectToInternet');
9089
if (connectionTransition) return t('pleaseWaitAMoment');
90+
if (!internetAvailable) return t('connectToInternet');
9191
if (accountInfo === null) return '';
9292
return t('connectToEnjoy');
9393
}
@@ -162,7 +162,6 @@ function ConnectionProgressBar() {
162162

163163
const connectingProgressBars = usePulsingProgress({ activated: isConnecting(connectionInProgress), bars: 2, inactiveColor: progressBg, w: 50 });
164164
const isOffline = !internetAvailable && !vpnConnected && !isConnecting(connectionInProgress);
165-
166165
return (
167166
<Paper shadow='xl' withBorder w='80%' maw={600} bg={bg} p='md' pt={5} pb='xs' mb='lg' radius='lg'>
168167
<Group mih={50} className={classes.connectionProgressBarGroup} align='center'>
@@ -186,15 +185,16 @@ function ConnectionProgressBar() {
186185
</>
187186
}
188187
{
189-
internetAvailable && !vpnConnected && !isConnecting(connectionInProgress) &&
188+
internetAvailable && (connectionInProgress === ConnectionInProgress.Disconnecting || (!vpnConnected && connectionInProgress === ConnectionInProgress.UNSET)) &&
190189
<Stack gap='xs' align='center' justify='flex-end' h={50}>
191190
<Progress className={classes.trafficVulnerableProgressBar} value={100} color='red.6' h={2} bg={progressBg} />
192191
<Text size='xs' c='red.6'>
193192
{t('trafficVulnerable')}
194193
</Text>
195194
</Stack>
196195
}
197-
{(vpnConnected || isConnecting(connectionInProgress)) && <>
196+
{
197+
((vpnConnected && connectionInProgress === ConnectionInProgress.UNSET) || isConnecting(connectionInProgress)) && <>
198198
{connectingProgressBars[0]}
199199
<Stack gap='0' align='center'>
200200
<ThemeIcon variant='transparent' c='white'>
@@ -538,7 +538,7 @@ function LocationSelect({ cityConnectingTo, setCityConnectingTo }: LocationSelec
538538
function LocationConnectTopCaption({ cityConnectingTo }: { cityConnectingTo: string | null }) {
539539
const { t } = useTranslation();
540540
const { vpnConnected, connectionInProgress } = useContext(AppContext);
541-
if (vpnConnected && connectionInProgress !== ConnectionInProgress.ChangingLocations)
541+
if (vpnConnected && connectionInProgress === ConnectionInProgress.UNSET)
542542
return <Text c='green.8' fw={550}>{t('connectedTo')}</Text>;
543543

544544
if (connectionInProgress === ConnectionInProgress.UNSET && !vpnConnected)

obscura-ui/src/views/LocationView.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ function VpnStatusCard() {
277277
if (connectionInProgress === ConnectionInProgress.ChangingLocations) {
278278
return t('trafficSuspended');
279279
}
280-
return vpnConnected ? t('trafficProtected') : t('trafficVulnerable');
280+
return (vpnConnected && connectionInProgress === ConnectionInProgress.UNSET) ? t('trafficProtected') : t('trafficVulnerable');
281281
};
282282

283283
const allowCancel = connectionInProgress === ConnectionInProgress.Connecting || connectionInProgress === ConnectionInProgress.Reconnecting;
@@ -297,7 +297,8 @@ function VpnStatusCard() {
297297
return t('busyConnection');
298298
};
299299

300-
const statusColor = vpnConnected ? 'green.7' : (connectionInProgress === ConnectionInProgress.ChangingLocations ? 'gray' : 'red.7');
300+
const statusColor = (vpnConnected && connectionInProgress === ConnectionInProgress.UNSET) ? 'green.7'
301+
: (connectionInProgress === ConnectionInProgress.ChangingLocations ? 'gray' : 'red.7');
301302

302303
return (
303304
<Card shadow='sm' padding='lg' radius='md' withBorder w='90%' mb='xs'>
@@ -306,7 +307,7 @@ function VpnStatusCard() {
306307
<Group align='center' gap={5}>
307308
<ThemeIcon color={statusColor} variant='transparent'>
308309
{connectionInProgress === ConnectionInProgress.ChangingLocations
309-
? <Loader size='xs' color='gray' /> : vpnConnected
310+
? <Loader size='xs' color='gray.5' /> : (vpnConnected && connectionInProgress === ConnectionInProgress.UNSET)
310311
? <BsShieldFillCheck size={25} />
311312
: <BsShieldFillExclamation size={25} />}
312313
</ThemeIcon>
@@ -318,7 +319,7 @@ function VpnStatusCard() {
318319
{getButtonContent()}
319320
</Button>
320321
</Group>
321-
{appStatus.vpnStatus.connected !== undefined &&
322+
{appStatus.vpnStatus.connected !== undefined && connectionInProgress !== ConnectionInProgress.Disconnecting &&
322323
<>
323324
<Divider my='md' />
324325
<Stack justify='space-between' w='100%'>

0 commit comments

Comments
 (0)