Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_onShowInFinderClick = () => {
Analytics.logEvent('Click Show in Finder');
FileSystem.openFolderAsync(this.props.projectRoot).catch(err => {
console.error(err);
});
};
_onOpenInTerminalClick = () => {
Analytics.logEvent('Click Open in Terminal');
FileSystem.openConsoleAsync(this.props.projectRoot).catch(err => {
console.error(err);
});
};
_newClickedAsync = async () => {
Analytics.logEvent('Click New');
await this._stopProjectAsync(this.state.projectRoot);
this.setState({
openModal: ModalEnum.NEW_PROJECT,
});
};
_openClickedAsync = async () => {
Analytics.logEvent('Click Open');
let root = await Commands.openExpAsync();
if (root) {
await this._startProjectAsync(root);
}
};
_closeClickedAsync = async () => {
Analytics.logEvent('Click Close');
await this._stopProjectAsync(this.state.projectRoot);
};
_onTogglePopover = (popover) => {
const isAlreadyOpen = this.state.openPopover === popover;
this.setState({openPopover: isAlreadyOpen ? null : popover});
if (!isAlreadyOpen) {
Analytics.logEvent('Open Popover', {
popover,
});
}
};
_newClickedAsync = async () => {
Analytics.logEvent('Click New');
this.setState({
openModal: ModalEnum.NEW_PROJECT,
});
};
_openClickedAsync = async () => {
Analytics.logEvent('Click Open');
await this._stopProjectAsync(this.state.projectRoot);
let root = await Commands.openExpAsync();
if (root) {
await this._startProjectAsync(root);
}
};
_restartClickedAsync = async (isShiftSelected = false) => {
Analytics.logEvent('Click Restart');
let clearCacheByDefault = await UserSettings.getAsync('clearCacheByDefault', true);
let reset = clearCacheByDefault ? !isShiftSelected : isShiftSelected;
let shiftMessage = '';
if (!isShiftSelected) {
shiftMessage = clearCacheByDefault
? ' (Hold shift while clicking restart to avoid clearing cache)'
: ' (Hold shift while clicking restart to clear packager cache)';
}
this._logInfo(
`Restarting project${reset ? ' and clearing packager cache' : ''}${shiftMessage}.`
);
this.setState(
{
_sendClickedAsync = async (sendTo) => {
Analytics.logEvent('Click Send');
this.setState({sendTo});
let url_ = this.state.computedUrl;
try {
await Exp.sendAsync(sendTo, url_);
this._logInfo(`Sent link ${url_} to ${sendTo}.`);
UserSettings.updateAsync('sendTo', sendTo);
} catch (err) {
this._logError(`Could not send link to ${sendTo}: ${err}`);
this._logError("If you're trying to SMS a link to a mobile device, make sure you are using the `+` sign and the country code at the beginning of the number.");
}
};