refactor main and rendered ipc
This commit is contained in:
parent
17e4b06948
commit
ddb2f4df0f
28 changed files with 758 additions and 211 deletions
27
src/ipcRend/account.ts
Normal file
27
src/ipcRend/account.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
|
||||
import { useIpc } from "@/modules/ipc";
|
||||
import { Profile } from "@/types";
|
||||
|
||||
const { invoke } = useIpc();
|
||||
|
||||
interface LoginPayload {
|
||||
email: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
|
||||
export const invokeProfile = async (): Promise<Profile | Error> => (
|
||||
await invoke('user-profile', null)
|
||||
);
|
||||
|
||||
|
||||
export const invokeLogin = async (
|
||||
payload: LoginPayload
|
||||
): Promise<Profile | Error> => (
|
||||
await invoke('user-login', JSON.stringify(payload))
|
||||
);
|
||||
|
||||
|
||||
export const invokeLogout = async (): Promise<void> => (
|
||||
await invoke("user-logout", null)
|
||||
);
|
||||
15
src/ipcRend/audio.ts
Normal file
15
src/ipcRend/audio.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
import { useIpc } from "@/modules/ipc";
|
||||
|
||||
|
||||
const { post, invoke } = useIpc();
|
||||
|
||||
|
||||
export const postStartRecord = (): void => (
|
||||
post("start-recording", null)
|
||||
);
|
||||
|
||||
|
||||
export const invokeStopRecord = async (): Promise<string | Error> => (
|
||||
await invoke("stop-recording", null)
|
||||
);
|
||||
21
src/ipcRend/session.ts
Normal file
21
src/ipcRend/session.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
import { useIpc } from "@/modules/ipc";
|
||||
|
||||
import { ClientMessage } from "@/types";
|
||||
|
||||
const { post } = useIpc();
|
||||
|
||||
|
||||
export const postMount = (): void => (
|
||||
post("app-mounted", null)
|
||||
);
|
||||
|
||||
|
||||
export const postInitSession = (cid: string): void => (
|
||||
post("init-session", cid)
|
||||
);
|
||||
|
||||
|
||||
export const postMessage = (payload: ClientMessage): void => (
|
||||
post('client-message', payload)
|
||||
);
|
||||
Loading…
Reference in a new issue