diff --git a/src/chrome/MainSidebar.tsx b/src/chrome/MainSidebar.tsx index 11715c7b8..6bf1fd84b 100644 --- a/src/chrome/MainSidebar.tsx +++ b/src/chrome/MainSidebar.tsx @@ -312,7 +312,7 @@ class MainSidebar extends PureComponent { onClick={() => setStaticView(SupportRequestForm)}> ; @@ -107,6 +109,10 @@ class PluginRowComponent extends Component { } export default class SelectPluginSheet extends Component { + static contextTypes = { + store: PropTypes.object.isRequired, + }; + state = {plugins: new Map()}; static getDerivedStateFromProps(props: Props, state: State) { if (state.plugins.size > 0) { @@ -128,7 +134,10 @@ export default class SelectPluginSheet extends Component { this.props.onSelect(selectedArray); } render() { - const {onHide} = this.props; + const onHide = () => { + this.context.store.dispatch(unsetShare()); + this.props.onHide(); + }; const {plugins} = this.state; return ( diff --git a/src/chrome/ShareSheet.tsx b/src/chrome/ShareSheet.tsx index 04116e6be..fd2561d9a 100644 --- a/src/chrome/ShareSheet.tsx +++ b/src/chrome/ShareSheet.tsx @@ -17,7 +17,11 @@ import { Input, } from 'flipper'; import React, {Component} from 'react'; -import {setExportStatusComponent, unsetShare} from '../reducers/application'; +import { + setExportStatusComponent, + unsetShare, + setExportURL, +} from '../reducers/application'; import {Logger} from '../fb-interfaces/Logger'; import {Idler} from '../utils/Idler'; import { @@ -127,7 +131,6 @@ export default class ShareSheet extends Component { `${EXPORT_FLIPPER_TRACE_EVENT}:UI_LINK`, ); - this.context.store.dispatch(unsetShare()); statusUpdate('Uploading Flipper Trace...'); const result = await reportPlatformFailures( shareFlipperData(serializedString), @@ -135,8 +138,10 @@ export default class ShareSheet extends Component { ); this.setState({errorArray, result}); - if ((result as DataExportResult).flipperUrl) { - clipboard.writeText(String((result as DataExportResult).flipperUrl)); + const flipperUrl = (result as DataExportResult).flipperUrl; + if (flipperUrl) { + clipboard.writeText(String(flipperUrl)); + this.context.store.dispatch(setExportURL(flipperUrl)); new Notification('Sharable Flipper trace created', { body: 'URL copied to clipboard', requireInteraction: true, @@ -159,6 +164,7 @@ export default class ShareSheet extends Component { } this.setState({result}); } + this.context.store.dispatch(unsetShare()); this.props.logger.trackTimeSince(mark, 'export:url-error'); } } @@ -208,6 +214,7 @@ export default class ShareSheet extends Component { render() { const onHide = () => { + this.context.store.dispatch(unsetShare()); this.props.onHide(); this.idler.cancel(); }; diff --git a/src/chrome/ShareSheetExportFile.tsx b/src/chrome/ShareSheetExportFile.tsx index 8e7eb808d..de6ead067 100644 --- a/src/chrome/ShareSheetExportFile.tsx +++ b/src/chrome/ShareSheetExportFile.tsx @@ -149,6 +149,7 @@ export default class ShareSheetExportFile extends Component { render() { const onHide = () => { + this.context.store.dispatch(unsetShare()); this.props.onHide(); this.idler.cancel(); }; diff --git a/src/reducers/application.tsx b/src/reducers/application.tsx index f0b930fe9..df7b21483 100644 --- a/src/reducers/application.tsx +++ b/src/reducers/application.tsx @@ -47,7 +47,10 @@ type SubShareType = type: 'file'; file: string; } - | {type: 'link'}; + | { + type: 'link'; + url?: string; + }; export type ShareType = { statusComponent?: React.ReactNode; @@ -117,6 +120,10 @@ export type Action = | { type: 'SET_EXPORT_STATUS_MESSAGE'; payload: React.ReactNode; + } + | { + type: 'SET_EXPORT_URL'; + payload: string; }; const initialState: () => State = () => ({ @@ -208,6 +215,12 @@ export default function reducer( return state; } else if (action.type === 'UNSET_SHARE') { return {...state, share: null}; + } else if (action.type === 'SET_EXPORT_URL') { + const share = state.share; + if (share && share.type === 'link') { + return {...state, share: {...share, url: action.payload}}; + } + return state; } else { return state; } @@ -270,3 +283,8 @@ export const setFlipperRating = (rating: number): Action => ({ rating, }, }); + +export const setExportURL = (result: string): Action => ({ + type: 'SET_EXPORT_URL', + payload: result, +});