Normalize export to fle and share link behaviour.

Summary:
Both export methods behaved slightly differently:
* Export to file returned earlier when running in background, which skiped the tracking of export termination;
* Share link always showed notification, even when on foreground;
* Share link status "hanged" - the share was never unset.

This change makes both consistent:
* Always track export finish - whether its in foreground or background;
* Only show notificaiton if running in background;
* Always reset the share/status.

On top of this it also:
* Normalizes the screenshot status to terminate in '...' as all the others;
* Only copies export URL to clipboard when exporting link if running in the background.

Reviewed By: passy

Differential Revision: D21425095

fbshipit-source-id: 9864a63269df6bd05ab065ff0e5d9f17b9ac6db6
This commit is contained in:
João Vieira
2020-05-07 04:02:41 -07:00
committed by Facebook GitHub Bot
parent a2d7297bbb
commit 64deaee5a7
3 changed files with 12 additions and 10 deletions

View File

@@ -125,15 +125,14 @@ export default class ShareSheetExportFile extends Component<Props, State> {
),
`${EXPORT_FLIPPER_TRACE_EVENT}:UI_FILE`,
);
this.store.dispatch(unsetShare());
if (this.state.runInBackground) {
new Notification('Shareable Flipper Export created', {
body: `Saved to ${this.props.file}`,
requireInteraction: true,
});
return;
}
this.setState({fetchMetaDataErrors, result: {kind: 'success'}});
this.store.dispatch(unsetShare());
this.props.logger.trackTimeSince(mark, 'export:file-success');
} catch (err) {
const result: {

View File

@@ -154,16 +154,19 @@ export default class ShareSheetExportUrl extends Component<Props, State> {
getLogger().trackTimeSince(uploadMarker, uploadMarker, {
plugins: this.store.getState().plugins.selectedPlugins,
});
this.setState({fetchMetaDataErrors, result});
const flipperUrl = (result as DataExportResult).flipperUrl;
if (flipperUrl) {
clipboard.writeText(String(flipperUrl));
this.store.dispatch(setExportURL(flipperUrl));
new Notification('Shareable Flipper Export created', {
body: 'URL copied to clipboard',
requireInteraction: true,
});
if (this.state.runInBackground) {
clipboard.writeText(String(flipperUrl));
new Notification('Shareable Flipper Export created', {
body: 'URL copied to clipboard',
requireInteraction: true,
});
}
}
this.setState({fetchMetaDataErrors, result});
this.store.dispatch(unsetShare());
this.store.dispatch(resetSupportFormV2State());
this.props.logger.trackTimeSince(mark, 'export:url-success');
} catch (e) {

View File

@@ -383,7 +383,7 @@ export const processStore = async (
if (device) {
const {serial} = device;
statusUpdate && statusUpdate('Capturing screenshot');
statusUpdate && statusUpdate('Capturing screenshot...');
const deviceScreenshot = await capture(device).catch((e) => {
console.warn('Failed to capture device screenshot when exporting. ' + e);
return null;
@@ -413,7 +413,7 @@ export const processStore = async (
idler,
);
statusUpdate && statusUpdate('Uploading screenshot');
statusUpdate && statusUpdate('Uploading screenshot...');
const deviceScreenshotLink =
deviceScreenshot &&
(await uploadFlipperMedia(deviceScreenshot, 'Image').catch((e) => {