Skip to content

Commit

Permalink
fix: async
Browse files Browse the repository at this point in the history
  • Loading branch information
mosshqq committed Dec 30, 2024
1 parent df39dc4 commit 5951e39
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
4 changes: 2 additions & 2 deletions packages/rpcs/wallet_getSidePanelEnabled/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const NAME = 'wallet_getSidePanelEnabled'

const getSidePanel = async () => {
const browser = (await import('webextension-polyfill')).default
browser.storage.local.get(SIDE_PANEL_KEY)
return browser.storage.local.get(SIDE_PANEL_KEY)
}

export const schemas = {
Expand All @@ -19,7 +19,7 @@ export const permissions = {
}

export const main = async ({rpcs: {wallet_getSidePanelSupported}}) => {
if (!wallet_getSidePanelSupported()) {
if (!(await wallet_getSidePanelSupported())) {
return false
}
const res = await getSidePanel()
Expand Down
19 changes: 5 additions & 14 deletions packages/rpcs/wallet_setSidePanelBehavior/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,10 @@ export const permissions = {
export const main = async ({
rpcs: {wallet_getSidePanelSupported, wallet_getSidePanelEnabled},
}) => {
const isSupported = await wallet_getSidePanelSupported()
if (!isSupported) return
const isEnabled = await wallet_getSidePanelEnabled()
const isSupported = wallet_getSidePanelSupported()
if (isEnabled) {
if (isSupported) {
await chrome.sidePanel.setPanelBehavior({
openPanelOnActionClick: true,
})
}
} else {
if (isSupported) {
await chrome.sidePanel.setPanelBehavior({
openPanelOnActionClick: false,
})
}
}
await chrome.sidePanel.setPanelBehavior({
openPanelOnActionClick: isEnabled,
})
}
4 changes: 2 additions & 2 deletions packages/rpcs/wallet_setSidePanelEnabled/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const NAME = 'wallet_setSidePanelEnabled'

const setSidePanel = async enabled => {
const browser = (await import('webextension-polyfill')).default
browser.storage.local.set({[SIDE_PANEL_KEY]: enabled})
return browser.storage.local.set({[SIDE_PANEL_KEY]: enabled})
}

export const schemas = {
Expand All @@ -22,7 +22,7 @@ export const main = async ({
params,
rpcs: {wallet_getSidePanelSupported, wallet_setSidePanelBehavior},
}) => {
if (!wallet_getSidePanelSupported()) {
if (!(await wallet_getSidePanelSupported())) {
throw new Error('Side panel is not supported')
}
await setSidePanel(params.enabled)
Expand Down

0 comments on commit 5951e39

Please sign in to comment.