mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-07 04:26:32 +08:00
To suppress the races, we mark these invocations with `void` per the instructions of `no-floating-promises`. This explicitly marks these statements as side-effect promises. Engineers can later analyze these void statements and determine whether the promise races are intentional or accidental. R=jacktfranklin@chromium.org Bug: 1239617 Change-Id: I6b7a24cf21029d6ff73b112b3e8255ebab8c60ec Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3366467 Reviewed-by: Jack Franklin <jacktfranklin@chromium.org> Commit-Queue: Tim Van der Lippe <tvanderlippe@chromium.org> Auto-Submit: Tim Van der Lippe <tvanderlippe@chromium.org>
45 lines
1.7 KiB
TypeScript
45 lines
1.7 KiB
TypeScript
// Copyright 2021 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import * as i18n from '../../core/i18n/i18n.js';
|
|
import type * as Platform from '../../core/platform/platform.js';
|
|
import type * as IssuesManager from '../../models/issues_manager/issues_manager.js';
|
|
|
|
import {AffectedResourcesView} from './AffectedResourcesView.js';
|
|
|
|
const UIStrings = {
|
|
/**
|
|
*@description Noun for singular or plural number of affected element resource indication in issue view.
|
|
*/
|
|
nElements: '{n, plural, =1 {# element} other {# elements}}',
|
|
};
|
|
const str_ = i18n.i18n.registerUIStrings('panels/issues/AffectedElementsView.ts', UIStrings);
|
|
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
|
|
export class AffectedElementsView extends AffectedResourcesView {
|
|
async #appendAffectedElements(affectedElements: Iterable<IssuesManager.Issue.AffectedElement>): Promise<void> {
|
|
let count = 0;
|
|
for (const element of affectedElements) {
|
|
await this.#appendAffectedElement(element);
|
|
count++;
|
|
}
|
|
this.updateAffectedResourceCount(count);
|
|
}
|
|
|
|
protected getResourceNameWithCount(count: number): Platform.UIString.LocalizedString {
|
|
return i18nString(UIStrings.nElements, {n: count});
|
|
}
|
|
|
|
async #appendAffectedElement(element: IssuesManager.Issue.AffectedElement): Promise<void> {
|
|
const cellElement = await this.createElementCell(element, this.issue.getCategory());
|
|
const rowElement = document.createElement('tr');
|
|
rowElement.appendChild(cellElement);
|
|
this.affectedResources.appendChild(rowElement);
|
|
}
|
|
|
|
update(): void {
|
|
this.clear();
|
|
void this.#appendAffectedElements(this.issue.elements());
|
|
}
|
|
}
|