Files
inji-wallet/components/BannerNotificationController.tsx
abhip2565 6e5c14b1fe [INJIMOB-2018] add vc download success banner (#1646)
[INJIMOB-1852] fix caching logic, to use cache if the device is offline

Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com>
2024-10-21 11:03:31 +05:30

45 lines
1.8 KiB
TypeScript

import {useSelector} from '@xstate/react';
import {
selectIsPasscodeUnlock,
selectIsBiometricUnlock,
SettingsEvents,
} from '../machines/settings';
import {useContext} from 'react';
import {GlobalContext} from '../shared/GlobalContext';
import {VcMetaEvents} from '../machines/VerifiableCredential/VCMetaMachine/VCMetaMachine';
import {
selectIsDownloadingFailed,
selectIsDownloadingSuccess,
selectWalletBindingSuccess,
} from '../machines/VerifiableCredential/VCMetaMachine/VCMetaSelectors';
import {selectVerificationStatus} from '../machines/VerifiableCredential/VCItemMachine/VCItemSelectors';
export const UseBannerNotification = () => {
const {appService} = useContext(GlobalContext);
const settingsService = appService.children.get('settings')!!;
const vcMetaService = appService.children.get('vcMeta')!!;
return {
isBindingSuccess: useSelector(vcMetaService, selectWalletBindingSuccess),
verificationStatus: useSelector(vcMetaService, selectVerificationStatus),
isPasscodeUnlock: useSelector(settingsService, selectIsPasscodeUnlock),
isBiometricUnlock: useSelector(settingsService, selectIsBiometricUnlock),
isDownloadingSuccess: useSelector(vcMetaService, selectIsDownloadingSuccess),
isDownloadingFailed: useSelector(vcMetaService, selectIsDownloadingFailed),
DISMISS: () => {
settingsService.send(SettingsEvents.DISMISS());
},
RESET_WALLET_BINDING_SUCCESS: () =>
vcMetaService.send(VcMetaEvents.RESET_WALLET_BINDING_SUCCESS()),
RESET_VERIFICATION_STATUS: () =>
vcMetaService.send(VcMetaEvents.RESET_VERIFICATION_STATUS(null)),
RESET_DOWNLOADING_FAILED: () => {
vcMetaService.send(VcMetaEvents.RESET_DOWNLOADING_FAILED());
},
RESET_DOWNLOADING_SUCCESS: () => {
vcMetaService.send(VcMetaEvents.RESET_DOWNLOADING_SUCCESS());
},
};
};