Skip to content

Commit 6448ad1

Browse files
committed
Address race condition
1 parent d94f5cb commit 6448ad1

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

front_end/panels/timeline/TimelinePanel.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,9 +1201,16 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
12011201
this.showScreenshotsToolbarCheckbox =
12021202
this.createSettingCheckbox(this.showScreenshotsSetting, i18nString(UIStrings.captureScreenshots));
12031203

1204-
// Hide this for now, this is to solve a timing problem with getting the platform metadata.
1205-
// This will be set back to visible only on Android.
1206-
this.showScreenshotsToolbarCheckbox.setVisible(false);
1204+
let showScreenshotsToggle = false;
1205+
1206+
const reactNativeApplicationModel = SDK.TargetManager.TargetManager.instance().primaryPageTarget()?.model(SDK.ReactNativeApplicationModel.ReactNativeApplicationModel);
1207+
if (reactNativeApplicationModel !== null && reactNativeApplicationModel !== undefined) {
1208+
showScreenshotsToggle = reactNativeApplicationModel.metadataCached?.platform === 'android';
1209+
}
1210+
1211+
// Only show this toggle if we are on android, to address a possible race condition with the platform metadata,
1212+
// this is also checked again on SDK.ReactNativeApplicationModel.Events.METADATA_UPDATED
1213+
this.showScreenshotsToolbarCheckbox.setVisible(showScreenshotsToggle);
12071214
this.panelToolbar.appendToolbarItem(this.showScreenshotsToolbarCheckbox);
12081215
}
12091216

0 commit comments

Comments
 (0)