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: prevent Transak window from showing on top of popups #1720

Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions packages/desktop/lib/electron/apis/electron.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,12 @@ export default {
closeTransak(): Promise<void> {
return ipcRenderer.invoke('close-transak')
},
minimizeTransak(): Promise<void> {
return ipcRenderer.invoke('minimize-transak')
},
restoreTransak(): Promise<void> {
return ipcRenderer.invoke('restore-transak')
},
isSidebarExpanded(expanded: boolean): Promise<void> {
return ipcRenderer.invoke('is-sidebar-expanded', expanded)
},
Expand Down
8 changes: 8 additions & 0 deletions packages/desktop/lib/electron/managers/transak.manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ export default class TransakManager implements ITransakManager {
}
}

public minimizeWindow(): void {
windows.transak?.minimize()
}

public restoreWindow(): void {
windows.transak?.restore()
}

public openWindow(data: ITransakWindowData): BrowserWindow {
if (windows.transak !== null) {
return windows.transak
Expand Down
8 changes: 8 additions & 0 deletions packages/desktop/lib/electron/processes/main.process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,14 @@ ipcMain.handle('is-sidebar-expanded', (_, expanded) => {
}
})

ipcMain.handle('minimize-transak', () => {
transakManager?.minimizeWindow()
})

ipcMain.handle('restore-transak', () => {
transakManager?.restoreWindow()
})

/**
* Create about window
* @returns {BrowserWindow} About window
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<script lang="ts">
import { Icon, IconName, Text } from '@bloomwalletio/ui'
import { AccountSwitcher, FormattedBalance } from '@components'
import { ISettingsState, settingsState } from '@contexts/settings/stores'
import { selectedAccount, selectedAccountIndex } from '@core/account/stores'
import { Platform } from '@core/app'
import { formatCurrency } from '@core/i18n'
import { getFiatAmountFromTokenValue } from '@core/market/actions'
import { activeProfile } from '@core/profile/stores'
import { ITokenWithBalance, formatTokenAmountBestMatch } from '@core/token'
import { selectedAccountTokens } from '@core/token/stores'
import { IPopupState, IProfileAuthPopupState, popupState, profileAuthPopup } from '@desktop/auxiliary/popup'
import { Pane } from '@ui'
import { onDestroy } from 'svelte'
import { onDestroy, tick } from 'svelte'

let tokenBalance: string
let fiatBalance: string
Expand All @@ -35,6 +37,20 @@
void resetTransak()
}

$: void handlePopupState($popupState, $profileAuthPopup, $settingsState)
async function handlePopupState(
state: IPopupState,
profilePopupState: IProfileAuthPopupState,
settingsState: ISettingsState
): Promise<void> {
if (state.active || profilePopupState.active || settingsState.open) {
await Platform.minimizeTransak()
} else {
await tick()
await Platform.restoreTransak()
}
}

onDestroy(() => {
void Platform.closeTransak()
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { ITransakWindowData } from '../transak-window-data.interface'
export interface ITransakManager {
openWindow(data: ITransakWindowData): void
closeWindow(): void
minimizeWindow(): void
restoreWindow(): void
positionWindow(): void
setSidebarExpanded(expanded: boolean): void
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export interface IPlatform {

openTransak(data: ITransakWindowData): Promise<void>
closeTransak(): Promise<void>
minimizeTransak(): Promise<void>
restoreTransak(): Promise<void>

isSidebarExpanded(expanded: boolean): Promise<void>
}
6 changes: 6 additions & 0 deletions packages/shared/test/mocks/platform.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ const Platform: IPlatform = {
closeTransak(): Promise<void> {
return Promise.resolve()
},
minimizeTransak(): Promise<void> {
return Promise.resolve()
},
restoreTransak(): Promise<void> {
return Promise.resolve()
},
isSidebarExpanded(expanded: boolean): Promise<void> {
return Promise.resolve()
},
Expand Down
Loading