Skip to content

Commit

Permalink
Add feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljscript committed Oct 10, 2024
1 parent f6a5c9c commit ed02302
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion apps/wallet-mobile/src/AppNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {SetupWalletNavigator} from './features/SetupWallet/SetupWalletNavigator'
import {useHasWallets} from './features/WalletManager/common/hooks/useHasWallets'
import {useStatusBar} from './hooks/useStatusBar'
import {agreementDate} from './kernel/config'
import {features} from './kernel/features'
import {AppRoutes, defaultStackNavigationOptions} from './kernel/navigation'
import {WalletNavigator} from './WalletNavigator'

Expand All @@ -46,7 +47,7 @@ const navRef = React.createRef<NavigationContainerRef<ReactNavigation.RootParamL
const prefixes = [...supportedPrefixes]

export const AppNavigator = () => {
useInitNotifications()
useInitNotifications({enabled: features.notifications})
useDeepLinkWatcher()
const strings = useStrings()
const [routeName, setRouteName] = React.useState<string>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const init = () => {
}
}

export const useInitNotifications = () => {
useEffect(() => init(), [])
useTransactionReceivedNotifications()
export const useInitNotifications = ({enabled}: {enabled: boolean}) => {
useEffect(() => (enabled ? init() : undefined), [enabled])
useTransactionReceivedNotifications({enabled})
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,20 @@ export const createTransactionReceivedNotification = (

export const transactionReceivedSubject = new Subject<NotificationTypes.TransactionReceivedEvent>()

export const useTransactionReceivedNotifications = () => {
export const useTransactionReceivedNotifications = ({enabled}: {enabled: boolean}) => {
const {walletManager} = useWalletManager()
const asyncStorage = useAsyncStorage()

React.useEffect(() => {
if (!enabled) return
registerBackgroundFetchAsync()
return () => {
unregisterBackgroundFetchAsync()
}
}, [])
}, [enabled])

React.useEffect(() => {
if (!enabled) return
const subscription = walletManager.syncWalletInfos$.subscribe(async (status) => {
const walletInfos = Array.from(status.values())
const walletsDoneSyncing = walletInfos.filter((info) => info.status === 'done')
Expand All @@ -131,7 +133,7 @@ export const useTransactionReceivedNotifications = () => {
return () => {
subscription.unsubscribe()
}
}, [walletManager, asyncStorage])
}, [walletManager, asyncStorage, enabled])
}

const buildStorage = (appStorage: App.Storage, walletId: string) => {
Expand Down
1 change: 1 addition & 0 deletions apps/wallet-mobile/src/kernel/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const features = {
prefillWalletInfo: false,
showProdPoolsInDev: isDev,
moderatingNftsEnabled: false,
notifications: isDev,
poolTransition: true,
portfolioSecondaryCharts: isDev,
portfolioPerformance: false,
Expand Down

0 comments on commit ed02302

Please sign in to comment.