Skip to content

Commit

Permalink
feat: Only log FlagshipUI changes if DEBUG boolean is true
Browse files Browse the repository at this point in the history
We want to reduce noise in console logs and FlagshipUI changes are not
so useful when not debuging this specific feature
  • Loading branch information
Ldoppea committed Jan 16, 2024
1 parent 13e0045 commit 43970bf
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/app/view/FlagshipUI/FlagshipUIService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ import { applyFlagshipUI } from '/libs/intents/setFlagshipUI'

const log = Minilog('🖌️ FlagshipUIService')

const DEBUG = false

function doLogDebug(...args: unknown[]): void {
if (DEBUG) {
log.debug(args)
}
}

export const flagshipUIEventHandler = new EventEmitter()

export const flagshipUIEvents = {
Expand Down Expand Up @@ -57,12 +65,12 @@ const renderFlagshipUiRecursive = (remaining: SettedUI[]): void => {
// Disabling false positive
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (last?.ui) {
log.debug('Update Flagship UI', last.ui, last.id)
doLogDebug('Update Flagship UI', last.ui, last.id)
applyFlagshipUI(last.ui, last.id)
} else if (remaining.length > 1) {
renderFlagshipUiRecursive(remaining.slice(1))
} else {
log.debug('Update Flagship UI with default')
doLogDebug('Update Flagship UI with default')
applyFlagshipUI(DEFAULT_FLAGSHIP_UI, 'default')
}
}
Expand All @@ -81,7 +89,7 @@ const registerService = (): void => {
zIndex: number,
defaultUi?: FlagshipUI
): void => {
log.debug(`🟢 Register component ${id}`)
doLogDebug(`🟢 Register component ${id}`)
if (!flagshipState.state.some(val => val.id === id)) {
flagshipState.state.push({
id,
Expand All @@ -99,14 +107,14 @@ const registerService = (): void => {
}

const unregisterComponent = (id: string): void => {
log.debug(`🔴 Unregister component ${id}`)
doLogDebug(`🔴 Unregister component ${id}`)

flagshipState.state = flagshipState.state.filter(o => o.id !== id)
renderFlagshipUI()
}

const setColor = (id: string, ui: FlagshipUI | undefined): void => {
log.debug(`🟠 Update component's color for ${id}`)
doLogDebug(`🟠 Update component's color for ${id}`)

const component = flagshipState.state.find(o => o.id === id)

Expand Down

0 comments on commit 43970bf

Please sign in to comment.