Skip to content

Commit

Permalink
fix: ensure graceful handling of when Firebase is disabled (#6460)
Browse files Browse the repository at this point in the history
### Description

As the title - currently there are some error banners and logs that are
incorrectly triggered.

### Test plan

n/a

### Related issues

- Related to RET-1289

### Backwards compatibility

Y

### Network scalability

If a new NetworkId and/or Network are added in the future, the changes
in this PR will:

- [ ] Continue to work without code changes, OR trigger a compilation
error (guaranteeing we find it when a new network is added)
  • Loading branch information
kathaypacific authored Jan 30, 2025
1 parent 0ab67bc commit d04bf52
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/app/ErrorMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export enum ErrorMessages {
ACCOUNT_UNLOCK_FAILED = 'accountUnlockFailed',
SEND_PAYMENT_FAILED = 'sendPaymentFailed',
ACCOUNT_SETUP_FAILED = 'accountSetupFailed',
FIREBASE_DISABLED = 'firebaseDisabled',
FIREBASE_FAILED = 'firebaseFailed',
IMPORT_CONTACTS_FAILED = 'importContactsFailed',
QR_FAILED_INVALID_ADDRESS = 'qrFailedInvalidAddress',
Expand Down
6 changes: 6 additions & 0 deletions src/fiatExchanges/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Action, Predicate } from '@redux-saga/types'
import BigNumber from 'bignumber.js'
import { SendOrigin } from 'src/analytics/types'
import { ActionTypes as AppActionTypes, Actions as AppActions } from 'src/app/actions'
import { FIREBASE_ENABLED } from 'src/config'
import {
Actions,
BidaliPaymentRequestedAction,
Expand Down Expand Up @@ -167,6 +168,11 @@ export function* tagTxsWithProviderInfo(action: UpdateTransactionsPayload) {
}

export function* importProviderLogos() {
if (!FIREBASE_ENABLED) {
Logger.info(`${TAG}/importProviderLogos`, 'Firebase disabled')
return
}

const providerLogos: ProviderLogos = yield readOnceFromFirebase('providerLogos')
yield* put(setProviderLogos(providerLogos))
}
Expand Down
5 changes: 5 additions & 0 deletions src/firebase/firebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,11 @@ export function simpleReadChannel(key: string) {
}

export async function readOnceFromFirebase(path: string) {
if (!FIREBASE_ENABLED) {
Logger.info(`${TAG}/readOnceFromFirebase`, 'Firebase disabled')
return null
}

const timeout = new Promise<void>((_, reject) =>
setTimeout(
() => reject(Error(`Reading from Firebase @ ${path} timed out.`)),
Expand Down
3 changes: 1 addition & 2 deletions src/firebase/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ export function* initializeFirebase() {
return
}
if (!FIREBASE_ENABLED) {
Logger.info(TAG, 'Firebase disabled')
yield* put(showError(ErrorMessages.FIREBASE_DISABLED))
Logger.info(`${TAG}/initializeFirebase`, 'Firebase disabled')
return
}

Expand Down
1 change: 0 additions & 1 deletion test/RootStateSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@
"fiatConnectKycStatusScreen.tryAgainFailed",
"fiatDetailsScreen.addFiatAccountFailed",
"fiatDetailsScreen.addFiatAccountResourceExist",
"firebaseDisabled",
"firebaseFailed",
"hooksPreview.invalidApiUrl",
"importBackupFailed",
Expand Down

0 comments on commit d04bf52

Please # to comment.