Skip to content

Commit

Permalink
fix(background): if wallet not connected, display default icon (#506)
Browse files Browse the repository at this point in the history
* If not connected, display default icon

* Fix lint

* reduce code nesting

* Update src/background/services/tabEvents.ts

---------

Co-authored-by: Sid Vishnoi <8426945+sidvishnoi@users.noreply.github.com>
  • Loading branch information
dianafulga and sidvishnoi authored Aug 16, 2024
1 parent 42a3bb7 commit 708838e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/background/services/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export class Background {
case PopupToBackgroundAction.DISCONNECT_WALLET:
await this.openPaymentsService.disconnectWallet()
await this.browser.alarms.clear(ALARM_RESET_OUT_OF_FUNDS)
await this.updateVisualIndicatorsForCurrentTab()
this.sendToPopup.send('SET_STATE', { state: {}, prevState: {} })
return

Expand Down
13 changes: 11 additions & 2 deletions src/background/services/tabEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,14 @@ export class TabEvents {
? this.tabState.tabHasAllSessionsInvalid(tabId)
: false
) => {
const { enabled, state } = await this.storage.get(['enabled', 'state'])
const { enabled, connected, state } = await this.storage.get([
'enabled',
'connected',
'state'
])
const { path, title, isMonetized } = this.getIconAndTooltip({
enabled,
connected,
state,
isTabMonetized,
hasTabAllSessionsInvalid
Expand All @@ -129,18 +134,22 @@ export class TabEvents {

private getIconAndTooltip({
enabled,
connected,
state,
isTabMonetized,
hasTabAllSessionsInvalid
}: {
enabled: Storage['enabled']
connected: Storage['connected']
state: Storage['state']
isTabMonetized: boolean
hasTabAllSessionsInvalid: boolean
}) {
let title = this.t('appName')
let iconData = ICONS.default
if (!isOkState(state) || hasTabAllSessionsInvalid) {
if (!connected) {
// use defaults
} else if (!isOkState(state) || hasTabAllSessionsInvalid) {
iconData = enabled ? ICONS.enabled_warn : ICONS.disabled_warn
const tabStateText = this.t('icon_state_actionRequired')
title = `${title} - ${tabStateText}`
Expand Down

0 comments on commit 708838e

Please sign in to comment.