Skip to content

Commit a694b69

Browse files
committed
refactor: change find to async
1 parent e2e84d4 commit a694b69

6 files changed

Lines changed: 117737 additions & 13 deletions

File tree

log-viewer/modules/components/analysis-view/AnalysisView.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ export class AnalysisView extends LitElement {
185185
return (this.tableContainer ??= this.renderRoot?.querySelector('#analysis-table'));
186186
}
187187

188-
_findEvt = ((event: FindEvt) => this._find(event)) as EventListener;
188+
_findEvt = ((event: FindEvt) => {
189+
this._find(event);
190+
}) as EventListener;
189191

190192
_groupBy(event: Event) {
191193
const target = event.target as HTMLInputElement;
@@ -208,7 +210,7 @@ export class AnalysisView extends LitElement {
208210
});
209211
}
210212

211-
_find(e: CustomEvent<{ text: string; count: number; options: { matchCase: boolean } }>) {
213+
async _find(e: CustomEvent<{ text: string; count: number; options: { matchCase: boolean } }>) {
212214
const isTableVisible = !!this.analysisTable?.element?.clientHeight;
213215
if (!isTableVisible && !this.totalMatches) {
214216
return;
@@ -226,8 +228,8 @@ export class AnalysisView extends LitElement {
226228
}
227229
if (newSearch || clearHighlights) {
228230
this.blockClearHighlights = true;
229-
//@ts-expect-error This is a custom function added in by Find custom module
230-
const result = this.analysisTable.find(this.findArgs);
231+
// @ts-expect-error This is a custom function added in by Find custom module
232+
const result = await this.analysisTable?.find(this.findArgs);
231233
this.blockClearHighlights = false;
232234
this.totalMatches = result.totalMatches;
233235
this.findMap = result.matchIndexes;

log-viewer/modules/components/calltree-view/CalltreeView.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,9 @@ export class CalltreeView extends LitElement {
218218
`;
219219
}
220220

221-
_findEvt = ((event: FindEvt) => this._find(event)) as EventListener;
221+
_findEvt = ((event: FindEvt) => {
222+
this._find(event);
223+
}) as EventListener;
222224

223225
_getAllTypes(data: LogLine[]): string[] {
224226
const flattened = this._flatten(data);
@@ -345,7 +347,7 @@ export class CalltreeView extends LitElement {
345347
this.calltreeTable.goToRow(treeRow, { scrollIfVisible: true, focusRow: true });
346348
}
347349

348-
_find(e: CustomEvent<{ text: string; count: number; options: { matchCase: boolean } }>) {
350+
async _find(e: CustomEvent<{ text: string; count: number; options: { matchCase: boolean } }>) {
349351
const isTableVisible = !!this.calltreeTable?.element?.clientHeight;
350352
if (!isTableVisible && !this.totalMatches) {
351353
return;
@@ -365,7 +367,7 @@ export class CalltreeView extends LitElement {
365367
if (newSearch || clearHighlights) {
366368
this.blockClearHighlights = true;
367369
//@ts-expect-error This is a custom function added in by Find custom module
368-
const result = this.calltreeTable.find(this.findArgs);
370+
const result = await this.calltreeTable.find(this.findArgs);
369371
this.blockClearHighlights = false;
370372
this.totalMatches = result.totalMatches;
371373
this.findMap = result.matchIndexes;

log-viewer/modules/components/calltree-view/module/Find.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class Find extends Module {
2222

2323
initialize() {}
2424

25-
_find(findArgs: FindArgs) {
25+
async _find(findArgs: FindArgs) {
2626
const result: { totalMatches: number; matchIndexes: { [key: number]: RowComponent } } = {
2727
totalMatches: 0,
2828
matchIndexes: {},

log-viewer/modules/components/database-view/DMLView.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ export class DMLView extends LitElement {
219219
this.oldIndex = highlightIndex;
220220
}
221221

222-
_find(e: CustomEvent<{ text: string; count: number; options: { matchCase: boolean } }>) {
222+
async _find(e: CustomEvent<{ text: string; count: number; options: { matchCase: boolean } }>) {
223223
const isTableVisible = !!this.dmlTable?.element?.clientHeight;
224224
if (!isTableVisible && !this.totalMatches) {
225225
return;
@@ -242,7 +242,7 @@ export class DMLView extends LitElement {
242242
if (newSearch || clearHighlights) {
243243
this.blockClearHighlights = true;
244244
//@ts-expect-error This is a custom function added in by Find custom module
245-
const result = this.dmlTable.find(this.findArgs);
245+
const result = await this.dmlTable.find(this.findArgs);
246246
this.blockClearHighlights = false;
247247
this.totalMatches = result.totalMatches;
248248
this.findMap = result.matchIndexes;

log-viewer/modules/components/database-view/SOQLView.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ export class SOQLView extends LitElement {
252252
this.oldIndex = highlightIndex;
253253
}
254254

255-
_find(e: CustomEvent<{ text: string; count: number; options: { matchCase: boolean } }>) {
255+
async _find(e: CustomEvent<{ text: string; count: number; options: { matchCase: boolean } }>) {
256256
const isTableVisible = !!this.soqlTable?.element?.clientHeight;
257257
if (!isTableVisible && !this.totalMatches) {
258258
return;
@@ -271,9 +271,9 @@ export class SOQLView extends LitElement {
271271
if (newSearch || clearHighlights) {
272272
this.blockClearHighlights = true;
273273
//@ts-expect-error This is a custom function added in by Find custom module
274-
const result = this.soqlTable.find(this.findArgs);
274+
const result = await this.soqlTable.find(this.findArgs);
275275
this.blockClearHighlights = false;
276-
this.totalMatches = 0;
276+
this.totalMatches = result.totalMatches;
277277
this.findMap = result.matchIndexes;
278278

279279
if (!clearHighlights) {

0 commit comments

Comments
 (0)