Get Active Window
This commit is contained in:
parent
e2b0561251
commit
42dd4da26b
|
|
@ -1,7 +1,7 @@
|
|||
// electron/ipc/tokenHandler.ts
|
||||
import { ipcMain } from 'electron';
|
||||
import { getToken, saveToken, clearToken } from '../utils/tokenHelper.js';
|
||||
import { handleLogin, takeScreenshot } from '../utils/utilityFunctions.js';
|
||||
import { getActiveApp, handleLogin, takeScreenshot } from '../utils/utilityFunctions.js';
|
||||
import api from '../api/axiosClient.js';
|
||||
|
||||
ipcMain.handle('get-token', async (_, TOKEN_KEY: "ACCESS_TOKEN" | "REFRESH_TOKEN") => {
|
||||
|
|
@ -41,3 +41,7 @@ ipcMain.handle('logout-request', async () => {
|
|||
return {success: false, message: ""}
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('get-active-app', () => {
|
||||
return getActiveApp();
|
||||
});
|
||||
|
|
@ -7,6 +7,7 @@ contextBridge.exposeInMainWorld('electron', {
|
|||
logout: () => ipcRenderer.invoke('logout-request'),
|
||||
getToken: (TOKEN_KEY: "ACCESS_TOKEN" | "REFRESH_TOKEN") => ipcRenderer.invoke('get-token', TOKEN_KEY),
|
||||
uploadScreenshot: () => ipcRenderer.invoke('upload-screenshot'),
|
||||
getActiveAppDetails: () => ipcRenderer.invoke('get-active-app'),
|
||||
} satisfies Window['electron']);
|
||||
|
||||
// function ipcInvoke<Key extends keyof EventPayloadMapping>(
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import path from "path";
|
|||
import axios from 'axios';
|
||||
import sharp from 'sharp';
|
||||
import { saveToken } from "./tokenHelper.js";
|
||||
import { activeWindow } from "get-windows";
|
||||
|
||||
// Blur using an offscreen canvas
|
||||
async function blurAndCompressBase64Image(base64: string): Promise<Buffer> {
|
||||
|
|
@ -93,3 +94,8 @@ export const handleLogin = async (credentials: { email: string, password: string
|
|||
return { success: false, error: "Unexpected error occurred" };
|
||||
}
|
||||
}
|
||||
|
||||
export const getActiveApp = async () => {
|
||||
const result = await activeWindow();
|
||||
return result;
|
||||
};
|
||||
|
|
@ -113,6 +113,16 @@ const DashboardLayout: React.FC<DashboardLayoutProps> = ({ setUser }) => {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
setInterval(async () => {
|
||||
const details = await window.electron.getActiveAppDetails()
|
||||
console.log(details)
|
||||
}, 15000)
|
||||
}, [])
|
||||
|
||||
|
||||
const toggleSidebar = () => setSidebarOpen(!isSidebarOpen);
|
||||
|
||||
const closeSidebarOnMobile = () => {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ interface Window {
|
|||
logout: () => Promise<any>;
|
||||
getToken: (tokenKey: "ACCESS_TOKEN" | "REFRESH_TOKEN") => Promise<string | null>;
|
||||
uploadScreenshot: () => {};
|
||||
getActiveAppDetails: () => {};
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue