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

[IMPROVEMENT] Share channel #908

Merged
merged 7 commits into from
May 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/containers/MessageActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion app/containers/MessageBox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
11 changes: 10 additions & 1 deletion app/lib/rocketchat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
},
Expand Down
12 changes: 10 additions & 2 deletions app/views/RoomActionsView/index.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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'
},
{
Expand Down Expand Up @@ -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;
Expand Down
13 changes: 7 additions & 6 deletions e2e/09-roomactions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down