diff --git a/app/containers/MessageActions.js b/app/containers/MessageActions.js index 05f6ff7461..2def876284 100644 --- a/app/containers/MessageActions.js +++ b/app/containers/MessageActions.js @@ -155,7 +155,7 @@ export default class MessageActions extends React.Component { getPermalink = async(message) => { try { - return await RocketChat.getPermalink(message); + return await RocketChat.getPermalinkMessage(message); } catch (error) { return null; } diff --git a/app/containers/MessageBox/index.js b/app/containers/MessageBox/index.js index c0753c40eb..810988f61e 100644 --- a/app/containers/MessageBox/index.js +++ b/app/containers/MessageBox/index.js @@ -245,7 +245,7 @@ class MessageBox extends Component { getPermalink = async(message) => { try { - return await RocketChat.getPermalink(message); + return await RocketChat.getPermalinkMessage(message); } catch (error) { return null; } diff --git a/app/lib/rocketchat.js b/app/lib/rocketchat.js index 0b47d301d2..01635f99c9 100644 --- a/app/lib/rocketchat.js +++ b/app/lib/rocketchat.js @@ -527,7 +527,7 @@ const RocketChat = { } return Promise.resolve(result); }, - async getPermalink(message) { + async getPermalinkMessage(message) { let room; try { room = await RocketChat.getRoom(message.rid); @@ -543,6 +543,15 @@ const RocketChat = { }[room.t]; return `${ server }/${ roomType }/${ room.name }?msg=${ message._id }`; }, + getPermalinkChannel(channel) { + const { server } = reduxStore.getState().server; + const roomType = { + p: 'group', + c: 'channel', + d: 'direct' + }[channel.t]; + return `${ server }/${ roomType }/${ channel.name }`; + }, subscribe(...args) { return this.sdk.subscribe(...args); }, diff --git a/app/views/RoomActionsView/index.js b/app/views/RoomActionsView/index.js index 9a3057cab3..2f4d60d7f5 100644 --- a/app/views/RoomActionsView/index.js +++ b/app/views/RoomActionsView/index.js @@ -1,7 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { - View, SectionList, Text, Alert + View, SectionList, Text, Alert, Share } from 'react-native'; import { connect } from 'react-redux'; import { SafeAreaView } from 'react-navigation'; @@ -241,7 +241,7 @@ export default class RoomActionsView extends React.Component { { icon: 'share', name: I18n.t('Share'), - disabled: true, + event: this.handleShare, testID: 'room-actions-share' }, { @@ -351,6 +351,14 @@ export default class RoomActionsView extends React.Component { } } + handleShare = () => { + const { room } = this.state; + const permalink = RocketChat.getPermalinkChannel(room); + Share.share({ + message: permalink + }); + }; + leaveChannel = () => { const { room } = this.state; const { leaveRoom } = this.props; diff --git a/e2e/09-roomactions.spec.js b/e2e/09-roomactions.spec.js index 9564077980..4f6f7e40e9 100644 --- a/e2e/09-roomactions.spec.js +++ b/e2e/09-roomactions.spec.js @@ -187,12 +187,13 @@ describe('Room actions screen', () => { await expect(element(by.id('room-actions-view'))).toBeVisible(); }); - it('should NOT navigate to share messages', async() => { - await waitFor(element(by.id('room-actions-share'))).toBeVisible().whileElement(by.id('room-actions-list')).scroll(scrollDown, 'down'); - await element(by.id('room-actions-share')).tap(); - await waitFor(element(by.id('room-actions-view'))).toBeVisible().withTimeout(2000); - await expect(element(by.id('room-actions-view'))).toBeVisible(); - }); + // TODO: test share room link + // it('should NOT navigate to share room', async() => { + // await waitFor(element(by.id('room-actions-share'))).toBeVisible().whileElement(by.id('room-actions-list')).scroll(scrollDown, 'down'); + // await element(by.id('room-actions-share')).tap(); + // await waitFor(element(by.id('room-actions-view'))).toBeVisible().withTimeout(2000); + // await expect(element(by.id('room-actions-view'))).toBeVisible(); + // }); after(async() => { takeScreenshot();