Change an IPC call to a fetch client-side. (#6294)

* Change an IPC call to a fetch client-side.

* fix fmt

* update
This commit is contained in:
Paul Tagliamonte
2025-04-11 19:59:27 -04:00
committed by GitHub
parent eea026f8e0
commit 9365186bed
2 changed files with 5 additions and 10 deletions

View File

@ -699,10 +699,12 @@ export const getUser = async (
hostname: string
): Promise<Models['User_type']> => {
try {
const user = await window.electron.kittycad('users.get_user_self', {
client: { token },
const user = await fetch(`${hostname}/users/me`, {
headers: new Headers({
Authorization: `Bearer ${token}`,
}),
})
return user
return user.json()
} catch (e) {
console.error(e)
}

View File

@ -1,7 +1,6 @@
// Some of the following was taken from bits and pieces of the vite-typescript
// template that ElectronJS provides.
// @ts-ignore: TS1343
import * as kittycad from '@kittycad/lib/import'
import * as packageJSON from '@root/package.json'
import type { Service } from 'bonjour-service'
import { Bonjour } from 'bonjour-service'
@ -373,12 +372,6 @@ ipcMain.handle('startDeviceFlow', async (_, host: string) => {
return handle.user_code
})
ipcMain.handle('kittycad', (event, data) => {
return data.access
.split('.')
.reduce((obj: any, prop: any) => obj[prop], kittycad)(data.args)
})
// Used to find other devices on the local network, e.g. 3D printers, CNC machines, etc.
ipcMain.handle('find_machine_api', () => {
const timeoutAfterMs = 5000