Skip to content

Commit 61ca433

Browse files
committed
Gate screenshots toggle to android only
1 parent 7f25433 commit 61ca433

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

front_end/panels/timeline/TimelinePanel.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,11 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
464464
*/
465465
#restoreSidebarVisibilityOnTraceLoad = false;
466466

467+
/**
468+
* Store React Native platform metadata (Android, iOS, etc.)
469+
*/
470+
#platformMetadata: Protocol.ReactNativeApplication.MetadataUpdatedEvent | null = null;
471+
467472
/**
468473
* Used to track an aria announcement that we need to alert for
469474
* screen-readers. We track these because we debounce announcements to not
@@ -712,8 +717,22 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
712717
SDK.ReactNativeApplicationModel.ReactNativeApplicationModel,
713718
{
714719
modelAdded: (model: SDK.ReactNativeApplicationModel.ReactNativeApplicationModel) => {
720+
model.addEventListener(
721+
SDK.ReactNativeApplicationModel.Events.METADATA_UPDATED,
722+
(event: Common.EventTarget.EventTargetEvent<Protocol.ReactNativeApplication.MetadataUpdatedEvent>) => {
723+
this.#platformMetadata = event.data;
724+
if (this.#platformMetadata.platform === 'android') {
725+
this.showScreenshotsToolbarCheckbox?.setVisible(true);
726+
}
727+
}
728+
);
715729
model.addEventListener(
716730
SDK.ReactNativeApplicationModel.Events.TRACE_REQUESTED, () => this.rnPrepareForTraceCapturedInBackground());
731+
732+
// Check if cached metadata is already available
733+
if (model.metadataCached) {
734+
this.#platformMetadata = model.metadataCached;
735+
}
717736
},
718737
modelRemoved: (_model: SDK.ReactNativeApplicationModel.ReactNativeApplicationModel) => {},
719738
},
@@ -1192,6 +1211,7 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
11921211
if (!isNode && !isReactNative) {
11931212
this.showScreenshotsToolbarCheckbox =
11941213
this.createSettingCheckbox(this.showScreenshotsSetting, i18nString(UIStrings.captureScreenshots));
1214+
this.showScreenshotsToolbarCheckbox.setVisible(false);
11951215
this.panelToolbar.appendToolbarItem(this.showScreenshotsToolbarCheckbox);
11961216
}
11971217

@@ -1389,6 +1409,13 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
13891409
this.timelinePane.element.appendChild(this.fileSelectorElement);
13901410
}
13911411

1412+
/**
1413+
* Helper method to check if the platform is Android
1414+
*/
1415+
#isAndroid(): boolean {
1416+
return this.#platformMetadata?.platform === 'Android';
1417+
}
1418+
13921419
private contextMenu(event: Event): void {
13931420
// Do not show this Context menu on FlameChart entries because we have a different context menu for FlameChart entries
13941421
const mouseEvent = (event as MouseEvent);

0 commit comments

Comments
 (0)