Merge remote-tracking branch 'origin/main' into main

automating dev and prod environments
This commit is contained in:
Andrew Gundersen 2021-05-21 14:36:25 -05:00
commit 17e4b06948
4 changed files with 43 additions and 24 deletions

View file

@ -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;
}
}
}

View file

@ -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.")
}

View file

@ -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.

View file

@ -1,8 +1,8 @@
<template>
<!-- Settings icon. -->
<button
class="settingsIcon"
<button
class="settingsIcon"
v-if="toggleSettings == false"
@click="onActive"
>
@ -13,13 +13,15 @@
<!-- Settings div. -->
<div id="settings" v-show="toggleSettings">
<button
</div>
<button
v-if="toggleSettings"
class="settingsOption"
@click="onLogout"
>
Logout
</button>
</div>
</template>
@ -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 {