From 9235a6c9bd5b4deb4f1528110df1901e2258be1e Mon Sep 17 00:00:00 2001 From: Brett <27568879+BrettCleary@users.noreply.github.com> Date: Thu, 7 Nov 2024 16:06:52 -0800 Subject: [PATCH] [Fix] toggle overlay (#1143) * init fix toggle overlay * update hp/overlay to alpha build * fix codecheck * prettier * update hp overlay * update ext provider and overlay --- package.json | 6 +-- src/backend/main.ts | 10 ++-- src/backend/overlay/api.ts | 7 ++- src/common/typedefs/ipcBridge.d.ts | 5 +- src/frontend/OverlayManager/Overlay/index.tsx | 2 +- .../components/QuestDetailsViewPlay/index.tsx | 1 + yarn.lock | 49 ++++++++----------- 7 files changed, 38 insertions(+), 42 deletions(-) diff --git a/package.json b/package.json index 1a5924650d..c6113894b9 100644 --- a/package.json +++ b/package.json @@ -171,7 +171,7 @@ "@hyperplay/check-disk-space": "^3.5.2", "@hyperplay/quests-ui": "^0.0.28", "@hyperplay/ui": "^1.8.8", - "@hyperplay/utils": "^0.2.4", + "@hyperplay/utils": "^0.3.3", "@mantine/carousel": "^7.12.0", "@mantine/core": "^7.12.0", "@mantine/dropzone": "^7.12.0", @@ -364,9 +364,9 @@ }, "optionalDependencies": { "@hyperplay/extension-importer": "^0.0.4", - "@hyperplay/extension-provider": "^0.0.7", + "@hyperplay/extension-provider": "^0.0.8", "@hyperplay/mock-backend": "^0.0.1", - "@hyperplay/overlay": "^0.0.6", + "@hyperplay/overlay": "^0.0.7", "@hyperplay/providers": "^0.0.6", "@hyperplay/proxy-server": "^0.0.11" }, diff --git a/src/backend/main.ts b/src/backend/main.ts index ed3bf273b8..449b4c7c3f 100644 --- a/src/backend/main.ts +++ b/src/backend/main.ts @@ -439,7 +439,7 @@ if (!gotTheLock) { // Someone tried to run a second instance, we should focus the overlay or the main window if no overlay is running. const hpOverlay = await getHpOverlay() if (hpOverlay?.overlayIsRunning()) { - hpOverlay.toggleOverlay({ action: 'ON' }) + hpOverlay.toggleOverlay({ action: 'ON', actionCause: 'AUTOMATED' }) } else { const mainWindow = getMainWindow() mainWindow?.show() @@ -484,8 +484,8 @@ if (!gotTheLock) { // keyboards with alt and no option key can be used with mac so register both const hpOverlay = await getHpOverlay() - const toggle = - hpOverlay?.toggleOverlay ?? + const toggle = () => + hpOverlay?.toggleOverlay({ action: 'TOGGLE', actionCause: 'HOTKEY' }) ?? (() => logInfo( 'Cannot toggle overlay without @hyperplay/overlay package', @@ -2069,9 +2069,9 @@ ipcMain.on('killOverlay', async () => { hpOverlay?.closeOverlay() }) -ipcMain.on('toggleOverlay', async () => { +ipcMain.on('toggleOverlay', async (ev, ...args) => { const hpOverlay = await getHpOverlay() - hpOverlay?.toggleOverlay() + hpOverlay?.toggleOverlay(...args) }) ipcMain.handle('getHyperPlayListings', async () => { diff --git a/src/backend/overlay/api.ts b/src/backend/overlay/api.ts index ad9ca5c8e7..95c1b89503 100644 --- a/src/backend/overlay/api.ts +++ b/src/backend/overlay/api.ts @@ -2,7 +2,8 @@ import { PROVIDERS, OverlayRenderState, OverlayMode, - ToastKey + ToastKey, + HyperPlayAPI } from '@hyperplay/utils' import { Toast } from './types' import { ipcRenderer } from 'electron' @@ -102,4 +103,6 @@ export const lockPopup = (lock: boolean) => ipcRenderer.send('lockPopup', lock) export const killOverlay = () => ipcRenderer.send('killOverlay') -export const toggleOverlay = () => ipcRenderer.send('toggleOverlay') +export const toggleOverlay = ( + args: Parameters[0] +) => ipcRenderer.send('toggleOverlay', args) diff --git a/src/common/typedefs/ipcBridge.d.ts b/src/common/typedefs/ipcBridge.d.ts index e75991c1d5..fa5fccb31a 100644 --- a/src/common/typedefs/ipcBridge.d.ts +++ b/src/common/typedefs/ipcBridge.d.ts @@ -54,7 +54,8 @@ import { MetaMaskInitMethod, ImportableBrowser, MetaMaskImportOptions, - ClientUpdateStatuses + ClientUpdateStatuses, + HyperPlayAPI } from '@hyperplay/utils' /** @@ -94,7 +95,7 @@ interface HyperPlaySyncIPCFunctions { toastCloseOnClick: (key: ToastKey) => void lockPopup: (lock: boolean) => void killOverlay: () => void - toggleOverlay: () => void + toggleOverlay: HyperPlayAPI['toggleOverlay'] authConnected: () => void goToGamePage: (gameId: string, action: GamePageActions) => void authDisconnected: () => void diff --git a/src/frontend/OverlayManager/Overlay/index.tsx b/src/frontend/OverlayManager/Overlay/index.tsx index 07dd9eb537..4bfc444957 100644 --- a/src/frontend/OverlayManager/Overlay/index.tsx +++ b/src/frontend/OverlayManager/Overlay/index.tsx @@ -74,7 +74,7 @@ export const Overlay = observer(function ({