Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load proxies only when visiting the proxy view #215

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions src/popup/App.vue
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
<script lang="ts" setup>
import { provide, onMounted } from 'vue';
import { provide } from 'vue';
import { useQueryProvider } from 'vue-query';
import { NConfigProvider, GlobalThemeOverrides, darkTheme } from 'naive-ui';

import Popup from '@/popup/Popup.vue';

import useConnection, { ConnectionKey } from '@/composables/useConnection';
import useListProxies from '@/composables/useListProxies';

const { isLoading, connection, isError } = useConnection();
const { getSocksProxies } = useListProxies();

provide(ConnectionKey, { connection, isLoading, isError });

const loadProxies = async () => {
await getSocksProxies();
};

onMounted(loadProxies);

useQueryProvider();
const themeOverrides: GlobalThemeOverrides = {
common: {
Expand Down
13 changes: 11 additions & 2 deletions src/popup/views/Proxy.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts" setup>
import { computed, inject } from 'vue';
import { computed, inject, onMounted } from 'vue';
import { NCard } from 'naive-ui';

import Button from '@/components/Buttons/Button.vue';
Expand All @@ -11,17 +11,26 @@ import TitleCategory from '@/components/TitleCategory.vue';

import useActiveTab from '@/composables/useActiveTab';
import { ConnectionKey, defaultConnection } from '@/composables/useConnection';
import useListProxies from '@/composables/useListProxies';
import useProxyPermissions from '@/composables/useProxyPermissions';

const { proxyPermissionsGranted, triggerProxyPermissions } = useProxyPermissions();
const { isAboutPage } = useActiveTab();
const { getSocksProxies } = useListProxies();
const { proxyPermissionsGranted, triggerProxyPermissions } = useProxyPermissions();

const { connection } = inject(ConnectionKey, defaultConnection);

const isWireGuard = computed(
() =>
connection.value.protocol === 'WireGuard' ||
connection.value.protocol === 'SOCKS through WireGuard',
);

const loadProxies = async () => {
await getSocksProxies();
};

onMounted(loadProxies);
</script>

<template>
Expand Down
Loading