Skip to content

Commit

Permalink
Load proxies only when visiting the proxy view
Browse files Browse the repository at this point in the history
  • Loading branch information
ruihildt committed Apr 24, 2024
1 parent 09f883b commit 58abf35
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
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

0 comments on commit 58abf35

Please sign in to comment.