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:
@ -699,10 +699,12 @@ export const getUser = async (
|
|||||||
hostname: string
|
hostname: string
|
||||||
): Promise<Models['User_type']> => {
|
): Promise<Models['User_type']> => {
|
||||||
try {
|
try {
|
||||||
const user = await window.electron.kittycad('users.get_user_self', {
|
const user = await fetch(`${hostname}/users/me`, {
|
||||||
client: { token },
|
headers: new Headers({
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
}),
|
||||||
})
|
})
|
||||||
return user
|
return user.json()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// Some of the following was taken from bits and pieces of the vite-typescript
|
// Some of the following was taken from bits and pieces of the vite-typescript
|
||||||
// template that ElectronJS provides.
|
// template that ElectronJS provides.
|
||||||
// @ts-ignore: TS1343
|
// @ts-ignore: TS1343
|
||||||
import * as kittycad from '@kittycad/lib/import'
|
|
||||||
import * as packageJSON from '@root/package.json'
|
import * as packageJSON from '@root/package.json'
|
||||||
import type { Service } from 'bonjour-service'
|
import type { Service } from 'bonjour-service'
|
||||||
import { Bonjour } from 'bonjour-service'
|
import { Bonjour } from 'bonjour-service'
|
||||||
@ -373,12 +372,6 @@ ipcMain.handle('startDeviceFlow', async (_, host: string) => {
|
|||||||
return handle.user_code
|
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.
|
// Used to find other devices on the local network, e.g. 3D printers, CNC machines, etc.
|
||||||
ipcMain.handle('find_machine_api', () => {
|
ipcMain.handle('find_machine_api', () => {
|
||||||
const timeoutAfterMs = 5000
|
const timeoutAfterMs = 5000
|
||||||
|
Reference in New Issue
Block a user