Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alerter: handle case of no alerts #530

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/widgets/Alerter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
ref="currentAlertBar"
class="flex items-center justify-between p-1 overflow-hidden rounded cursor-pointer select-none whitespace-nowrap bg-slate-800/75"
>
<p class="mx-1 overflow-hidden text-xl font-medium text-gray-100">{{ currentAlert.message }}</p>
<p class="mx-1 overflow-hidden text-xl font-medium text-gray-100">{{ currentAlert?.message }}</p>
<div class="flex flex-col justify-center mx-1 font-mono text-xs font-semibold leading-3 text-right text-gray-100">
<p>{{ formattedDate(currentAlert.time_created || new Date()) }}</p>
<p>{{ formattedDate(currentAlert?.time_created || new Date()) }}</p>
<p>{{ currentAlert.level.toUpperCase() }}</p>
</div>
</div>
Expand Down Expand Up @@ -47,7 +47,7 @@ const alertPersistencyInterval = 10 // in seconds

const formattedDate = (datetime: Date): string => format(datetime, 'HH:mm:ss')

const currentAlert = ref(alertStore.alerts[0])
const currentAlert = ref(alertStore.alerts?.[0] ?? undefined)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to return undefined, optional chaining already returns that.


// eslint-disable-next-line no-undef
let currentAlertInterval: NodeJS.Timer | undefined = undefined
Expand Down