From 9e08c6db93603aa4d949e40d69f7a7617246c64e Mon Sep 17 00:00:00 2001 From: Priyank Patel Date: Fri, 11 Jun 2021 18:01:13 +0000 Subject: [PATCH] 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. --- static/js/ui_report.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/js/ui_report.js b/static/js/ui_report.js index 2cd84a0c03..cb973834f8 100644 --- a/static/js/ui_report.js +++ b/static/js/ui_report.js @@ -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);