Skip to content

Commit

Permalink
Update supportedBrowser structure on the Features model
Browse files Browse the repository at this point in the history
  • Loading branch information
ronaldsg20 committed Dec 9, 2024
1 parent 0b3b4b0 commit b374d16
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/common/components/exchange/SelectBitcoinWallet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ import { useAction, useGetter, useStateAttribute } from '@/common/store/helper';
import walletConf from '@/common/walletConf.json';
import { mdiArrowLeft } from '@mdi/js';
import { useTheme } from 'vuetify';
import { Browser, Feature, FeatureNames } from '@/common/types';
import {
Browser, Feature, FeatureNames, SupportedBrowsers,
} from '@/common/types';
import { getBrowserName } from '@/common/utils';
export default {
Expand All @@ -68,8 +70,11 @@ export default {
const wallets = computed(() => walletConf.wallets.filter((wallet) => {
const walletConfJsonConstant = wallet.constant as BtcWallet;
const flag = getFeature.value(FeatureNames[walletConfJsonConstant]);
return (flag?.value === constants.ENABLED)
&& (flag.supportedBrowsers.includes(currentBrowser));
if (!flag) {
return false;
}
const browserFlag = Object.keys(flag).includes('supportedBrowsers') ? flag.supportedBrowsers[currentBrowser.toLowerCase() as keyof SupportedBrowsers] : false;
return (flag?.value === constants.ENABLED) && browserFlag;
}));
const bitcoinWallet = useStateAttribute<BtcWallet>('pegInTx', 'bitcoinWallet');
Expand Down
12 changes: 11 additions & 1 deletion src/common/types/Feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,19 @@ export enum Browser {
BRAVE = 'Brave',
OPERA = 'Opera',
}

export interface SupportedBrowsers {
chrome: boolean;
firefox: boolean;
safari: boolean;
edge: boolean;
brave: boolean;
chromium: boolean;
opera: boolean;
}
export interface Feature {
name: FeatureNames;
value: string;
version: number;
supportedBrowsers: Browser[];
supportedBrowsers: SupportedBrowsers;
}
3 changes: 2 additions & 1 deletion src/common/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
RequestBalance,
PegoutStatus,
SatoshiBig,
Browser,
} from '@/common/types';
import { BridgeService } from '@/common/services/BridgeService';
import moment from 'moment';
Expand Down Expand Up @@ -126,7 +127,7 @@ export function getBrowserName() {
}

export function isAllowedCurrentBrowser() {
return getBrowserName() === 'Chrome' || window.navigator.brave;
return getBrowserName() === Browser.CHROME || window.navigator.brave;
}

export function isBTCAmountValidRegex(bitcoinAmount: string) {
Expand Down

0 comments on commit b374d16

Please sign in to comment.