Skip to content

Commit

Permalink
Set 'P' badge when proxy is toggled on
Browse files Browse the repository at this point in the history
  • Loading branch information
ruihildt committed Nov 24, 2023
1 parent fc1e29a commit b287b8a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
8 changes: 0 additions & 8 deletions extension/assets/icons/route-blocked-w.svg

This file was deleted.

7 changes: 0 additions & 7 deletions extension/assets/icons/route.svg

This file was deleted.

13 changes: 13 additions & 0 deletions src/composables/useExtBadge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const setExtBadge = (text: string) => {
browser.browserAction.setBadgeBackgroundColor({ color: '#ffd524' });
browser.browserAction.setBadgeTextColor({ color: 'black' });
browser.browserAction.setBadgeText({ text });
};

const useExtBadge = () => {
return {
setExtBadge,
};
};

export default useExtBadge;
6 changes: 5 additions & 1 deletion src/composables/useSocksProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import getSocksIpForProtocol from './utils/getSocksIpForProtocol';

import useStore from '@/composables/useStore';
import useConnection from '@/composables/useConnection';
import useExtBadge from '@/composables/useExtBadge';

const { connection, updateConnection } = useConnection();
const { setExtBadge } = useExtBadge();
const { globalProxyDetails, globalProxy, customProxies, customProxiesDetails } = useStore();

const globalProxyEnabled = computed(() => globalProxyDetails.value.socksEnabled);
Expand All @@ -26,6 +28,7 @@ const disableGlobalProxy = () => {
...globalProxyDetails.value,
socksEnabled: false,
};
setExtBadge('');
updateConnection();
};

Expand All @@ -34,6 +37,7 @@ const enableGlobalProxy = () => {
...globalProxyDetails.value,
socksEnabled: true,
};
setExtBadge('P');
updateConnection();
};

Expand All @@ -45,7 +49,7 @@ const initGlobalProxy = async (
protocol: string,
) => {
// Create a default globalProxy if there's none yet
// We don't do it it in the bakground script, because we don't want to make a request on extension start
// We don't do it it in the background script, because we don't want to make a request on extension start
if (Object.keys(globalProxy.value).length !== 4) {
const socksIp = getSocksIpForProtocol(protocol);

Expand Down

0 comments on commit b287b8a

Please sign in to comment.