From b0eaab3be225b0c2a83e84229c70db16e4519f18 Mon Sep 17 00:00:00 2001 From: ckitsanelis Date: Thu, 23 Nov 2023 15:50:50 +0100 Subject: [PATCH] Change timing of ColumnType extraction for persistence --- src/viewer/App.tsx | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/src/viewer/App.tsx b/src/viewer/App.tsx index 6f8d163..01d3e1e 100644 --- a/src/viewer/App.tsx +++ b/src/viewer/App.tsx @@ -69,9 +69,9 @@ interface State { } -let searchText = ""; -let searchColumn = "All"; let searchTimeoutId; +let searchText: string = ""; +let searchColumn: string = "All"; let logHeaderColumnTypes: StructureHeaderColumnType[] = []; export default class App extends React.Component { @@ -120,6 +120,7 @@ export default class App extends React.Component { const logEntryCharIndexMaps = useGetCharIndicesForLogEntries(logFileText); const logFile = LogFile.create(lines, rules); logFile.setSelectedColumns(this.state.selectedColumns, this.state.selectedColumnsMini) + this.extractHeaderColumnTypes(logFile, rules); this.setState({ rules, logFile, @@ -142,6 +143,25 @@ export default class App extends React.Component { } } + extractHeaderColumnTypes(logFile: LogFile, rules: Rule[]) { + logHeaderColumnTypes = []; + for (let h = 0; h < logFile.headers.length; h++) { + let headerType = StructureHeaderColumnType.Selected; + + if (logFile.headers[h].name.toLowerCase() === "timestamp") { + headerType = StructureHeaderColumnType.Unselected; + } + + rules.forEach((rule) => { + if (rule.column === logFile.headers[h].name) { + headerType = StructureHeaderColumnType.Custom; + } + }); + + logHeaderColumnTypes.push(headerType); + } + } + updateSearchField() { clearTimeout(searchTimeoutId); searchTimeoutId = setTimeout(this.updateSearchMatches, 1000); @@ -226,7 +246,6 @@ export default class App extends React.Component { handleStructureDialog(isClosing: boolean) { if (isClosing === true) { - logHeaderColumnTypes = []; this.handleStructureUpdate(isClosing); } else { const { logFile, rowProperties, rules, showStructureDialog } = this.state; @@ -240,22 +259,7 @@ export default class App extends React.Component { } if (!showStructureDialog) { - for (let h = 0; h < logFile.headers.length; h++) { - let headerType = StructureHeaderColumnType.Selected; - - if (logFile.headers[h].name.toLowerCase() === "timestamp") { - headerType = StructureHeaderColumnType.Unselected; - } - - rules.forEach((rule) => { - if (rule.column === logFile.headers[h].name) { - headerType = StructureHeaderColumnType.Custom; - } - }); - - logHeaderColumnTypes.push(headerType); - } - + this.extractHeaderColumnTypes(logFile, rules); this.setState({ showStructureDialog: true }); }