Show the warning about JSON format only once
Bug: b/258217645
Change-Id: I9e2ebba2301670189e38941b2918904d83f678fe
diff --git a/ui/src/controller/trace_controller.ts b/ui/src/controller/trace_controller.ts
index bd5d4d0..046db9e 100644
--- a/ui/src/controller/trace_controller.ts
+++ b/ui/src/controller/trace_controller.ts
@@ -147,6 +147,10 @@
defaultValue: false,
});
+// A local storage key where the indication that JSON warning has been shown is
+// stored.
+const SHOWN_JSON_WARNING_KEY = 'shownJsonWarning';
+
function showJsonWarning() {
showModal({
title: 'Warning',
@@ -162,7 +166,7 @@
m('br')),
buttons: [],
});
-};
+}
// TraceController handles handshakes with the frontend for everything that
// concerns a single trace. It owns the WASM trace processor engine, handles
@@ -405,7 +409,10 @@
endSec,
};
- {
+ const shownJsonWarning =
+ window.localStorage.getItem(SHOWN_JSON_WARNING_KEY) !== null;
+
+ if (!shownJsonWarning) {
// Show warning if the trace is in JSON format.
const query = `select str_value from metadata where name = 'trace_type'`;
const result = await assertExists(this.engine).query(query);
@@ -414,8 +421,11 @@
// it passes to Perfetto, so we don't need to show this warning.
if (traceType.str_value == 'json' && !frontendGlobals.embeddedMode) {
showJsonWarning();
+ // Save that the warning has been shown. Value is irrelevant since only
+ // the presence of key is going to be checked.
+ window.localStorage.setItem(SHOWN_JSON_WARNING_KEY, 'true');
}
- };
+ }
const emptyOmniboxState = {
omnibox: '',