Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Expensify.cash to iOS and Android native share menus #1361

Merged
merged 17 commits into from
Feb 4, 2021
Merged

Add Expensify.cash to iOS and Android native share menus #1361

merged 17 commits into from
Feb 4, 2021

Conversation

r8
Copy link
Collaborator

@r8 r8 commented Jan 29, 2021

Details

Uses react-native-share-menu to add Expensify.cash to the native share menu on mobile platforms and enables sharing to the app.

Chat selection is made on separate page, which reuses components from Home page. To achieve this I had to modify some sidebar related components and functions, mainly to add callbacks for getting selected chat id.

Fixed Issues

Fixes #1294

Tests

  1. Open some other app on iOS or Android, for example image gallery or web browser.
  2. Activate share menu for the element that needs to be shared.
  3. Confirm that Expensify.cash is present in Share menu.
  4. Select Expensify.cash.
  5. Confirm that Expensify.cash is opened and routes to Send to... page.
  6. Select or create and select some chat.
  7. Confirm that shared item is posted to selected chat.

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

iOS

ShareMenu-iOS.mp4

Android

ShareMenu-Android.mp4

@github-actions
Copy link
Contributor

github-actions bot commented Jan 29, 2021

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@r8 r8 marked this pull request as ready for review January 31, 2021 22:34
@r8 r8 requested a review from a team as a code owner January 31, 2021 22:34
@r8 r8 changed the title [WIP] Add Expensify.cash to iOS and Android native share menus Add Expensify.cash to iOS and Android native share menus Jan 31, 2021
@botify botify requested review from TomatoToaster and removed request for a team January 31, 2021 22:35
@TomatoToaster
Copy link
Contributor

Great job on this! I gave this a passthrough and it looks good but it seems like there might be some unintended differences as a result of a merge conflict? Could you give it a look and resolve the merge conflicts before I give it a full review?

@r8
Copy link
Collaborator Author

r8 commented Feb 2, 2021

@TomatoToaster Oh, sorry. It seems that something has been merged after I've submitted the PR, and I haven't noticed it until now.
I'll resolve the conflicts shortly.

@TomatoToaster
Copy link
Contributor

No problem at all, Thanks!

@r8
Copy link
Collaborator Author

r8 commented Feb 2, 2021

@TomatoToaster Conflicts are resolved

Copy link
Contributor

@TomatoToaster TomatoToaster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey sorry, this took a bit for me to review, but this mostly looks good! I had a few adjustments requested. LMK what you think.

src/pages/home/sidebar/SidebarLinks.js Outdated Show resolved Hide resolved
src/pages/SharePage.js Outdated Show resolved Hide resolved

COCOAPODS: 1.10.0
COCOAPODS: 1.10.1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind reverting to 1.10.0 to build this project? We haven't switched to 1.10.1 quite yet and it would help keep our mobile repos in sync.

I managed to do it by reinstalling the cocoapods gem to that version and deleting this file before a pod install.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to use 1.10.1, because you have this version in your Gemfile.lock

https://github.com/Expensify/Expensify.cash/blob/d353a46e95efd3e9d0df85134e078aa0e859b8fa/Gemfile.lock#L34

I had 1.10.0 too, but pod install wasn't working and was showing following error: Could not find proper version of cocoapods (1.10.1) in any of the sources.

So I'm not sure how to proceed. I can revert to 1.10.0, but are you sure that it will work?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see, I didn't realize it was locked to that version in the gemfile. Let me double check on that.

Copy link
Contributor

@TomatoToaster TomatoToaster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty good to me, let me double check about the gemfile situation.

@TomatoToaster TomatoToaster merged commit 0e371a5 into Expensify:master Feb 4, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Feb 4, 2021
Copy link
Contributor

@marcaaron marcaaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have not tested this but just leaving some thoughts...

Probably we should be have used the new OptionsList instead of ChatSwitcherView for this as the latter will be deleted soon. The adaptation of the SidebarLinks for use in SharePage could benefit from some clean up. Seems like there is a lot of duplication which will make this code hard to maintain.

* @param {Object} sharedItem
*/
function handleShare(sharedItem) {
if (sharedItem) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be an early return

* Removes share events listener.
*/
function deregister() {
listener.remove();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we set the listener back to undefined? Probably we should not call remove() if it doesn't exist. Have seen this happen with some other listeners.

onClose={this.toggleCreateMenu}
isVisible={this.state.isCreateMenuActive}
onItemSelected={this.onCreateMenuItemSelected}
/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably don't need the CreateMenu here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with the FAB?

@@ -241,7 +245,8 @@ class ChatSwitcherView extends React.Component {
*/
startGroupChat() {
const userLogins = _.map(this.state.usersToStartGroupReportWith, option => option.login);
fetchOrCreateChatReport([this.props.session.email, ...userLogins]);
fetchOrCreateChatReport([this.props.session.email, ...userLogins])
.then(this.props.onReportSelected);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused about why we added this. And if this is what we want why did we not add a .then() to fetchOrCreateChatReport() instead adding it to several usages?

@@ -504,6 +504,7 @@ function fetchAll(shouldRedirectToReport = true, shouldFetchActions = false, sho
* set of participants
*
* @param {String[]} participants
* @returns {Promise} reportID
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should this return a Promise?

redirect(this.props.currentlyViewedReportID !== ''
? ROUTES.getReportRoute(this.props.currentlyViewedReportID)
: ROUTES.HOME);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like duplicated redirect logic here. Maybe could have abstracted this somehow.

paddingLeft: 20,
paddingRight: 0,
paddingVertical: 12,
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than create a new style we should use padding spacing helpers.

onPress={this.props.onCloseButtonClick}
>
<Icon src={Close} />
</TouchableOpacity>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could probably be refactored into a CloseButton component.

isActive={this.props.network && !this.props.network.isOffline}
/>
</TouchableOpacity>
{this.props.showCloseButton && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we need to add things like showCloseButton and showAvatar then it might make more sense to reduce the responsibility of these components and use a version that allows adding in the header parts where they are needed instead of a new prop to make optional.

} else {
fetchOrCreateChatReport([this.props.session.email, selectedOption.login]);
fetchOrCreateChatReport([this.props.session.email, selectedOption.login])
.then(this.props.onReportSelected);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just FYI this entire file will be removed very soon and this change makes it difficult to do.

MARKETING_VERSION = 1.0.1;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.chat.expensify.chat.ShareExtension;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey also as a note, there might need to be more done with adding this bundle. The logs for our iOS deploy shows there was an error with this identifier.

In the new PR we can figure out fixes for this and what needs to be done.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Improvement] Add expensify.cash to iOS and Android native share menus
3 participants