remove user-message & agen-message event listeners

This commit is contained in:
riqo 2021-02-24 11:42:05 -06:00
commit 3bf9f54df2
11 changed files with 51 additions and 98 deletions

View file

@ -16,10 +16,9 @@ const AUTH_KEY = 'crimata_token';
const token = window.localStorage.getItem(AUTH_KEY);
const authToken = async () => {
const { data, invoke } = useIpc('auth-session');
const { invoke } = useIpc();
try {
await invoke(token);
state.accessToken = data.value;
state.accessToken = await invoke('auth-session', token);
}
catch(e) {
state.error = e;

View file

@ -1,28 +1,15 @@
import { ref, computed } from 'vue'
export const useIpc = (endpoint: string) => {
const data = ref();
const error = ref();
const errorMessage = computed(() => {
console.log('ERROR', error.value);
if (error.value) {
return error.value.message
}
})
const invoke = async (payload: any) => {
error.value = undefined;
export const useIpc = () => {
const invoke = async (endpoint: string, payload: any) => {
try {
const res = await window.ipcRenderer.invoke(endpoint, payload);
return data.value = res;
return res;
} catch (e) {
error.value = e;
throw e;
}
}
const post = (payload: any) => {
const post = (endpoint: string, payload: any) => {
window.postMessage({
endpoint: endpoint,
content: payload
@ -30,9 +17,6 @@ export const useIpc = (endpoint: string) => {
};
return {
data,
error,
errorMessage,
invoke,
post
}