function shareSession(session: Session): ThunkAction { return (dispatch, getState) => { const {sessionURLTemplate} = getState().config; const url = sessionURLTemplate .replace('{slug}', session.slug) .replace('{id}', session.id); if (Platform.OS === 'ios') { ActionSheetIOS.showShareActionSheetWithOptions({ message: session.title, url, }, (e) => console.error(e), logShare.bind(null, session.id)); } else { Share.open({ share_text: session.title, share_URL: url, title: 'Share Link to ' + session.title, }, (e) => logShare(session.id, true, null)); } }; }
function removeFromScheduleWithPrompt(session: Session): ThunkAction { return (dispatch) => { if (Platform.OS === 'ios') { ActionSheetIOS.showActionSheetWithOptions({ options: ['Remove From Schedule', 'Cancel'], destructiveButtonIndex: 0, cancelButtonIndex: 1, }, (buttonIndex) => { if (buttonIndex === 0) { dispatch(removeFromSchedule(session.id)); } }); } else { Alert.alert( 'Remove From Your Schedule', `Would you like to remove "${session.title}" from your schedule?`, [ {text: 'Cancel'}, { text: 'Remove', onPress: () => dispatch(removeFromSchedule(session.id)) }, ] ); } }; }