From: riqo Date: Sun, 28 Feb 2021 20:27:51 +0000 (-0600) Subject: add splash screen on load X-Git-Tag: v0.9~66 X-Git-Url: https://andrewgundersen.net/repos?a=commitdiff_plain;h=346bfcba019701739d0aa0ab9988aea693387124;p=mime-chat add splash screen on load --- diff --git a/src/App.vue b/src/App.vue index 583ff1b..17e28a1 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,5 +1,5 @@ diff --git a/src/background/audio.ts b/src/background/audio.ts index 3263582..4424d44 100644 --- a/src/background/audio.ts +++ b/src/background/audio.ts @@ -35,7 +35,9 @@ export const initAudioIO = () => { }); ai.on('data', (chunk: string) => { // turn string base64 data into buffer object. - audioInput.push(Buffer.from(chunk, encoding)); + console.log('received string chunk of length', chunk.length) + const buf = Buffer.from(chunk, encoding); + audioInput.push(buf); }); } @@ -54,7 +56,8 @@ export const updateRecorder = (_event, record: boolean): void => { } else { // stop mic data flow on space bar key up. ai.pause(); - sendAudio(Buffer.concat(audioInput)); + const audio = Buffer.concat(audioInput); + sendAudio(audio); audioInput = []; } } diff --git a/src/background/window.ts b/src/background/window.ts index 334ae67..b84a742 100644 --- a/src/background/window.ts +++ b/src/background/window.ts @@ -30,10 +30,11 @@ let win: BrowserWindow | null; const windowMount = (): void => { backgroundMitt.emit('window-active', true); + ipcMain.removeAllListeners('update-recorder'); ipcMain.on('update-recorder', updateRecorder); - // handle renderer auth-token event - ipcMain.removeHandler('nav-bar'); // avoid setting duplicate handlers - ipcMain.handle('nav-bar', navBarHandler); + // handle renderer auth-token event + ipcMain.removeHandler('nav-bar'); // avoid setting duplicate handlers + ipcMain.handle('nav-bar', navBarHandler); } const windowDismount = (): void => { @@ -58,6 +59,7 @@ export const createWindow = async (options: WindowSettings): Promise => { width: options.width, height: options.height, resizable: options.resizable, + backgroundColor: '#EBEBEB', frame: false, minWidth: 350, minHeight: 500, @@ -82,8 +84,12 @@ export const createWindow = async (options: WindowSettings): Promise => { // Handle window close. win.on("closed", windowDismount); + win.once('ready-to-show', () => { + if (win) win.show() + }) + win.webContents.on('did-finish-load', () => { - windowMount(); + windowMount(); resolve(); }); diff --git a/src/components/messageItem.vue b/src/components/messageItem.vue new file mode 100644 index 0000000..d60795e --- /dev/null +++ b/src/components/messageItem.vue @@ -0,0 +1,140 @@ + + + + + \ No newline at end of file diff --git a/src/views/splash.vue b/src/components/splash.vue similarity index 53% rename from src/views/splash.vue rename to src/components/splash.vue index d30173d..247847a 100644 --- a/src/views/splash.vue +++ b/src/components/splash.vue @@ -1,57 +1,55 @@ @@ -68,4 +66,4 @@ export default defineComponent({ } - \ No newline at end of file + diff --git a/src/modules/auth.ts b/src/modules/auth.ts index 6a1120e..c541c3f 100644 --- a/src/modules/auth.ts +++ b/src/modules/auth.ts @@ -1,4 +1,4 @@ -import { reactive, toRefs } from 'vue'; +import { reactive, toRefs, ref } from 'vue'; import { useIpc } from './ipc'; interface AuthState { @@ -11,6 +11,8 @@ const state = reactive({ error: undefined, }); +const loading = ref(true); + const AUTH_KEY = 'crimata_token'; const token = window.localStorage.getItem(AUTH_KEY); @@ -20,6 +22,7 @@ if (token) { } const authToken = async () => { + loading.value = true; const { invoke } = useIpc(); try { const res = await invoke('auth-session', token); @@ -32,6 +35,7 @@ const authToken = async () => { window.localStorage.removeItem(AUTH_KEY); state.accessToken = null; } + loading.value = false; } // authenticate on auth event @@ -56,5 +60,6 @@ export const useAuth = () => { setToken, logout, ...toRefs(state), // accessToken, error + loading } } diff --git a/src/router.ts b/src/router.ts index d3459dc..ee94a61 100644 --- a/src/router.ts +++ b/src/router.ts @@ -5,7 +5,6 @@ import { RouteRecordRaw } from "vue-router"; import Home from "@/views/messenger.vue"; -import Splash from "@/views/splash.vue"; import { useAuth } from '@/modules/auth'; // Define the routes (/*) for the app here. @@ -16,14 +15,6 @@ const routes: Array = [ component: Home, meta: { requiresAuth: true }, }, - { - path: "/splash", - name: "splash", - component: Splash, - meta: { - requiresAuth: false - }, - }, { path: "/login", name: "login", diff --git a/src/views/messenger.vue b/src/views/messenger.vue index 58f0094..25ebd75 100644 --- a/src/views/messenger.vue +++ b/src/views/messenger.vue @@ -3,74 +3,37 @@ -
- - -
- - -
- - -
- {{ message.content }} -
- - - - - -
- -
- -
- {{ message.avatar }} -
- - {{ message.context }} - -
- -
- -
- +
+
- +