From aab9ae136d001c514e8fa22fedf9e81d4a58e1de Mon Sep 17 00:00:00 2001 From: Enrique Hernandez Date: Sat, 17 Apr 2021 12:57:22 -0400 Subject: [PATCH 1/3] add userData config path to helper functions --- src/background/helpers.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/background/helpers.ts b/src/background/helpers.ts index bd3d279..f0074fb 100644 --- a/src/background/helpers.ts +++ b/src/background/helpers.ts @@ -1,7 +1,9 @@ import fs from 'fs'; import { backgroundMitt } from "@/modules/emitter"; import { SessionState, WindowState } from "@/types"; +import { app } from "electron"; +const configPath = app.getPath("userData"); export const ipcEmit = (channel: string, payload: any) => { backgroundMitt.emit('ipc-renderer', { @@ -14,7 +16,7 @@ export const loadState = (fileName: string): SessionState => { let state: SessionState; try { - state = JSON.parse(fs.readFileSync(fileName).toString()); + state = JSON.parse(fs.readFileSync(configPath + fileName).toString()); } catch (error) { @@ -32,7 +34,7 @@ export const loadWinState = (fileName: string): WindowState => { let state: WindowState; try { - state = JSON.parse(fs.readFileSync(fileName).toString()); + state = JSON.parse(fs.readFileSync(configPath + fileName).toString()); } catch (error) { @@ -51,7 +53,7 @@ export const loadWinState = (fileName: string): WindowState => { // Save session or window state. export const saveToJson = (fileName: string, data: any) => { - fs.writeFile(fileName, JSON.stringify(data), (err) => { + fs.writeFile(configPath + fileName, JSON.stringify(data), (err) => { if (err) { console.log("Error when saving to json.") } From 7c2f3cad8cfcecdb98cdb2d6e5e6fb3bae5f0de6 Mon Sep 17 00:00:00 2001 From: riqo Date: Mon, 26 Apr 2021 07:22:38 -0500 Subject: [PATCH 2/3] fix audio stream shutdown --- src/background/audio.ts | 33 +++++++++++++++++++++------------ src/background/init.ts | 5 +++-- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/background/audio.ts b/src/background/audio.ts index 6dd3bdd..0a98206 100644 --- a/src/background/audio.ts +++ b/src/background/audio.ts @@ -40,7 +40,7 @@ const onRecordingEnd = async (_event: any, payload: any) => { try { resolve(audioContainer.input); - record = false; + record = false; } catch (e) { reject() } @@ -120,7 +120,7 @@ export function play(input: string): void { // Format the audio. const audio = bufSplit( - Buffer.from(input as string, 'hex'), + Buffer.from(input as string, 'hex'), 8192 ); @@ -165,15 +165,24 @@ export function play(input: string): void { // ------------------------------------------------------------- // Get's called on window close. -// export function stopStream() { -// console.log("AUDIO:Stopping audio stream.") -// if (ai) { -// ai.quit() -// } -// if (ao) { -// ao.quit() -// } -// console.log("AUDIO:Audio closed.") -// } +export async function stopStream() { + console.log("AUDIO:Stopping audio stream.") + if (ai) { + try { + await ai.quit() + } catch(e){ + console.log('AUDIO: Failed to shutdown audio input.'); + throw e; + } + } + if (ao) { + try { + await ao.quit() + } catch(e){ + console.log('AUDIO: Failed to shutdown audio output.'); + throw e; + } + } +} diff --git a/src/background/init.ts b/src/background/init.ts index 715228a..a17716c 100644 --- a/src/background/init.ts +++ b/src/background/init.ts @@ -4,7 +4,7 @@ import { app, dialog } from "electron"; import { createWindow } from './window'; import { initSession } from './session'; -import { initAudioIO } from './audio'; +import { initAudioIO, stopStream } from './audio'; import { backgroundMitt } from '@/modules/emitter'; let win: boolean; @@ -63,7 +63,8 @@ export function initApp(dev: boolean): void { }); // Must keep to ensure app doesn't quit on close. - app.on("before-quit", () => { + app.on("before-quit", async () => { + await stopStream(); }); // Must keep to ensure app doesn't quit on close. From 730cb4b31a7706300673e5b9ee9dab1eabc6e9b0 Mon Sep 17 00:00:00 2001 From: riqo Date: Mon, 26 Apr 2021 07:44:43 -0500 Subject: [PATCH 3/3] fix transparent logout button --- src/components/settings.vue | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/components/settings.vue b/src/components/settings.vue index a70b797..51347b2 100644 --- a/src/components/settings.vue +++ b/src/components/settings.vue @@ -1,8 +1,8 @@ @@ -27,7 +29,7 @@ import { defineComponent, ref } from "vue"; import { useIpc } from "@/modules/ipc"; - import { logoutRequest } from '@/modules/message'; + import { logoutRequest } from '@/modules/message'; export default defineComponent({ name: "Settings", @@ -58,7 +60,7 @@ } return { - onActive, + onActive, toggleSettings, onLogout } @@ -141,6 +143,11 @@ border: none; outline: none; text-decoration: none; + position: absolute; + left: 50%; + top: 50%; + transform: translate(-50%, -50%); + z-index: 5; } .settingsOption:hover {