mirror of
https://github.com/mosip/inji-wallet.git
synced 2026-01-09 13:38:01 -05:00
feat(#305): Extract use ble enabled to a constant instead of env check
This commit is contained in:
@@ -9,7 +9,9 @@ const { Openid4vpBle } = OpenIdBle;
|
||||
type ShareProtocol = OpenIDBLEShare | IdpassSmartshareType;
|
||||
let ShareLib: ShareProtocol;
|
||||
|
||||
if (USE_BLE_SHARE === 'true') {
|
||||
export const isBLEEnabled = USE_BLE_SHARE === 'true';
|
||||
|
||||
if (isBLEEnabled) {
|
||||
ShareLib = Openid4vpBle;
|
||||
} else {
|
||||
ShareLib = IdpassSmartshare;
|
||||
|
||||
@@ -22,6 +22,7 @@ import { pure, respond } from 'xstate/lib/actions';
|
||||
import { AppServices } from '../shared/GlobalContext';
|
||||
import { request } from '../shared/request';
|
||||
import { USE_BLE_SHARE } from 'react-native-dotenv';
|
||||
import { isBLEEnabled } from '../lib/smartshare';
|
||||
|
||||
const model = createModel(
|
||||
{
|
||||
@@ -197,14 +198,14 @@ export const appMachine = model.createMachine(
|
||||
activityLogMachine.id
|
||||
);
|
||||
|
||||
serviceRefs.scan = USE_BLE_SHARE
|
||||
serviceRefs.scan = isBLEEnabled
|
||||
? spawn(
|
||||
BLEScan.createScanMachine(serviceRefs),
|
||||
BLEScan.scanMachine.id
|
||||
)
|
||||
: spawn(createScanMachine(serviceRefs), scanMachine.id);
|
||||
|
||||
serviceRefs.request = USE_BLE_SHARE
|
||||
serviceRefs.request = isBLEEnabled
|
||||
? spawn(
|
||||
BLERequest.createRequestMachine(serviceRefs),
|
||||
BLERequest.requestMachine.id
|
||||
|
||||
@@ -14,6 +14,7 @@ import { useTranslation } from 'react-i18next';
|
||||
import { LanguageSelector } from '../../components/LanguageSelector';
|
||||
import i18next, { SUPPORTED_LANGUAGES } from '../../i18n';
|
||||
import { USE_BLE_SHARE } from 'react-native-dotenv';
|
||||
import { isBLEEnabled } from '../../lib/smartshare';
|
||||
|
||||
const LanguageSetting: React.FC = () => {
|
||||
const { t } = useTranslation('ProfileScreen');
|
||||
@@ -86,7 +87,7 @@ export const ProfileScreen: React.FC<MainRouteProps> = (props) => {
|
||||
<ListItem.Content>
|
||||
<ListItem.Title>
|
||||
<Text color={Theme.Colors.profileLabel}>
|
||||
{USE_BLE_SHARE === 'true' ? t('useBle') : t('useGoogleNearby')}
|
||||
{isBLEEnabled ? t('useBle') : t('useGoogleNearby')}
|
||||
</Text>
|
||||
</ListItem.Title>
|
||||
</ListItem.Content>
|
||||
|
||||
@@ -50,8 +50,6 @@ export function offlineSubscribe<T extends SmartshareEventType>(
|
||||
callback: (data: SmartshareEventData<T>) => void
|
||||
) {
|
||||
return IdpassSmartshare.handleNearbyEvents(({ type, data }) => {
|
||||
console.log({ type, data });
|
||||
console.log('{type, data}');
|
||||
if (type !== 'msg') return;
|
||||
|
||||
const response = SmartshareEvent.fromString<T>(data);
|
||||
|
||||
Reference in New Issue
Block a user