Fix the regressed deeplink support for crash reporter plugin

Summary: The deeplink from crash notification to crash reporter plugin was broken. It always showed the latest crash.With this diff the crashreporter plugin shows the correct crash information.

Reviewed By: danielbuechele

Differential Revision: D13487792

fbshipit-source-id: eee6826bb0a84d0aab9b432a1c9a04aa7d528402
This commit is contained in:
Pritesh Nandgaonkar
2018-12-19 06:57:57 -08:00
committed by Facebook Github Bot
parent 3135c99cc5
commit ade6eabdb0

View File

@@ -126,11 +126,22 @@ export default class CrashReporterPlugin extends FlipperDevicePlugin {
};
render() {
const crash =
this.props.persistedState.crashes.length > 0 &&
this.props.persistedState.crashes[
this.props.persistedState.crashes.length - 1
];
let crash: ?Crash =
this.props.persistedState.crashes.length > 0
? this.props.persistedState.crashes[
this.props.persistedState.crashes.length - 1
]
: null;
if (this.props.deepLinkPayload) {
const id = this.props.deepLinkPayload;
const index = this.props.persistedState.crashes.findIndex(elem => {
return elem.notificationID === Number(id);
});
if (index >= 0) {
crash = this.props.persistedState.crashes[index];
}
}
if (crash) {
const callstackString = crash.callstack;
@@ -162,7 +173,11 @@ export default class CrashReporterPlugin extends FlipperDevicePlugin {
</CrashRow>
{this.device.os == 'Android' && (
<CrashRow>
<Button onClick={() => this.openInLogs(crash.callstack)}>
<Button
onClick={() => {
//$FlowFixMe: checked that crash is not undefined
this.openInLogs(crash.callstack);
}}>
Open in Logs
</Button>
</CrashRow>