Skip to content

Commit 3978b05

Browse files
committed
Rename and cleanup permissions request
1 parent 6430378 commit 3978b05

File tree

3 files changed

+19
-35
lines changed

3 files changed

+19
-35
lines changed

Diff for: src/components/OptionsTabs/ProxyTab.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import LocationDrawer from '@/components/ConnectionDetails/LocationDrawer.vue';
88
import TitleCategory from '@/components/TitleCategory.vue';
99
1010
import useProxyPermissions from '@/composables/useProxyPermissions';
11-
const { proxyPermissionsGranted, triggerRequestProxyPermissions } = useProxyPermissions();
11+
const { isGranted, requestPermissions } = useProxyPermissions();
1212
</script>
1313

1414
<template>
15-
<template v-if="proxyPermissionsGranted">
15+
<template v-if="isGranted">
1616
<CustomProxies />
1717
<LocationDrawer />
1818
</template>
@@ -31,7 +31,7 @@ const { proxyPermissionsGranted, triggerRequestProxyPermissions } = useProxyPerm
3131
</ul>
3232
</IconLabel>
3333

34-
<Button class="mt-3" @click="triggerRequestProxyPermissions"> Grant permissions </Button>
34+
<Button class="mt-3" @click="requestPermissions"> Grant permissions </Button>
3535
</n-card>
3636
</template>
3737
</template>

Diff for: src/components/Proxy/HomeProxyStatus.vue

+5-24
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { checkDomain } from '@/helpers/domain';
1818
const { activeTabHost, isBrowserPage } = useActiveTab();
1919
const { updateConnection } = useConnection();
2020
const { proxySelect } = useLocations();
21-
const { proxyPermissionsGranted, triggerRequestProxyPermissions } = useProxyPermissions();
21+
const { isGranted, requestPermissions } = useProxyPermissions();
2222
const { getSocksProxies } = useSocksProxies();
2323
const {
2424
allowProxy,
@@ -132,7 +132,7 @@ watch([currentHostProxyEnabled, subDomainProxyEnabled, domainProxyDetails, exclu
132132

133133
<template>
134134
<n-tabs
135-
v-if="proxyPermissionsGranted"
135+
v-if="isGranted"
136136
type="line"
137137
justify-content="start"
138138
:value="activeTab"
@@ -275,41 +275,22 @@ watch([currentHostProxyEnabled, subDomainProxyEnabled, domainProxyDetails, exclu
275275
</div>
276276
</div>
277277
</n-tab-pane>
278-
279-
<n-tab-pane
280-
v-if="!proxyPermissionsGranted"
281-
name="permissions"
282-
tab="Permissions missing"
283-
class="flex flex-col"
284-
>
285-
<ul>
286-
<li>- <strong>tabs</strong> to show proxy settings from the active tab</li>
287-
<li>- <strong>proxy</strong> to configure and use Mullvad proxy servers</li>
288-
<li>- <strong>&lt;all_urls&gt;</strong> to have granular proxy settings</li>
289-
</ul>
290-
291-
<Button size="small" class="mt-3" @click="triggerRequestProxyPermissions">
292-
Grant permissions
293-
</Button>
294-
</n-tab-pane>
295278
</n-tabs>
296279

297-
<n-tabs v-if="!proxyPermissionsGranted" type="line" justify-content="start">
280+
<n-tabs v-else type="line" justify-content="start">
298281
<template #prefix>
299282
<TitleCategory title="Proxy" />
300283
</template>
301284

302-
<n-tab-pane v-if="!proxyPermissionsGranted" name="permissions" tab="Permissions missing">
285+
<n-tab-pane name="permissions" tab="Permissions missing">
303286
<div class="flex flex-col">
304287
<ul>
305288
<li>- <strong>tabs</strong> to show proxy settings from the active tab</li>
306289
<li>- <strong>proxy</strong> to configure and use Mullvad proxy servers</li>
307290
<li>- <strong>&lt;all_urls&gt;</strong> to have granular proxy settings</li>
308291
</ul>
309292

310-
<Button size="small" class="mt-3" @click="triggerRequestProxyPermissions">
311-
Grant permissions
312-
</Button>
293+
<Button size="small" class="mt-3" @click="requestPermissions"> Grant permissions </Button>
313294
</div>
314295
</n-tab-pane>
315296
</n-tabs>

Diff for: src/composables/useProxyPermissions.ts

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1-
import { ref } from 'vue';
1+
import { ref, readonly } from 'vue';
22
import { getProxyPermissions, requestProxyPermissions } from '@/helpers/permissions';
33

4-
const useProxyPermissions = () => {
5-
const proxyPermissionsGranted = ref(false);
4+
export const useProxyPermissions = () => {
5+
const isGranted = ref(false);
66

77
const checkProxyPermissions = async () => {
8-
proxyPermissionsGranted.value = await getProxyPermissions();
8+
isGranted.value = await getProxyPermissions();
99
};
1010

11-
const triggerRequestProxyPermissions = async () => {
12-
proxyPermissionsGranted.value = await requestProxyPermissions();
13-
return proxyPermissionsGranted.value;
11+
const requestPermissions = async (): Promise<boolean> => {
12+
isGranted.value = await requestProxyPermissions();
13+
return isGranted.value;
1414
};
1515

1616
checkProxyPermissions();
1717

18-
return { proxyPermissionsGranted, triggerRequestProxyPermissions };
18+
return {
19+
isGranted: readonly(isGranted),
20+
requestPermissions,
21+
};
1922
};
2023

2124
export default useProxyPermissions;

0 commit comments

Comments
 (0)