banner logic

This commit is contained in:
cupcakearmy 2021-06-10 22:23:27 +02:00
parent 14ac96366e
commit 1b691949a3
No known key found for this signature in database
GPG Key ID: D28129AE5654D9D9

View File

@ -1,13 +1,11 @@
import { join } from 'path' import { join } from 'path'
import os from 'os' import os from 'os'
import { app, BrowserWindow, BrowserWindowConstructorOptions, ipcMain } from 'electron' import { app, BrowserWindow, BrowserWindowConstructorOptions, ipcMain } from 'electron'
import dayjs from 'dayjs'
import logger from 'electron-log'
import ms from 'ms'
import { DEV } from '.' import { DEV } from '.'
import Settings from './settings' import Settings from './settings'
import TrayUtility from './tray' import TrayUtility from './tray'
import { InputDevicesStatus } from './utils'
export default class Banner { export default class Banner {
static interval: ReturnType<typeof setInterval> static interval: ReturnType<typeof setInterval>
@ -22,18 +20,21 @@ export default class Banner {
}) })
} }
static shouldShow(): boolean {
const [paused, interval] = Settings.getStatus()
if (paused || interval > 1000) return false
if (InputDevicesStatus.areCameraOrMicrophoneActive()) return true
return true
}
static check() { static check() {
TrayUtility.build() TrayUtility.build()
const [paused, interval] = Settings.getStatus() if (Banner.shouldShow()) Banner.open()
if (!paused && interval < 1000) {
Banner.open()
}
} }
static open() { static open() {
if (this.window) return if (this.window) return
logger.debug('Showing banner')
const options: BrowserWindowConstructorOptions = { const options: BrowserWindowConstructorOptions = {
frame: false, frame: false,
webPreferences: { webPreferences: {