ui_report: Correctly check if remove_after is passed.

We use a simpler approach here which is to let it be undefined if
nothing was passed and use that in the if condition. This has two
benefits. There is no edge case where the condition will evaluate to
false if 0 was passed and it is easier to type annotate.
This commit is contained in:
Priyank Patel 2021-06-11 18:01:13 +00:00 committed by Tim Abbott
parent 5ae523891b
commit 9e08c6db93
1 changed files with 2 additions and 2 deletions

View File

@ -10,7 +10,7 @@ import {$t} from "./i18n";
cls- class that we want to add/remove to/from the status_box
*/
export function message(response_html, status_box, cls = "alert", remove_after = false) {
export function message(response_html, status_box, cls = "alert", remove_after) {
// Note we use html() below, since we can rely on our callers escaping HTML
// via $t_html when interpolating data.
status_box
@ -19,7 +19,7 @@ export function message(response_html, status_box, cls = "alert", remove_after =
.html(response_html)
.stop(true)
.fadeTo(0, 1);
if (remove_after) {
if (remove_after !== undefined) {
setTimeout(() => {
status_box.fadeOut(400);
}, remove_after);