Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(background): if wallet not connected, display default icon #506

Merged
merged 4 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: boolean
sidvishnoi marked this conversation as resolved.
Show resolved Hide resolved
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
Loading