Added missing events and fixed channels list
This commit is contained in:
parent
4761e21de8
commit
7d2924e2e9
|
@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
|
|||
import { Animated } from 'react-native';
|
||||
import { PanGestureHandler, State } from 'react-native-gesture-handler';
|
||||
|
||||
import Touch from '../../utils/touch';
|
||||
import {
|
||||
ACTION_WIDTH,
|
||||
SMALL_SWIPE,
|
||||
|
@ -10,7 +11,6 @@ import {
|
|||
} from './styles';
|
||||
import { isRTL } from '../../i18n';
|
||||
import { LeftActions, RightActions } from './Actions';
|
||||
import Touch from '../../utils/touch';
|
||||
|
||||
class Touchable extends React.Component {
|
||||
static propTypes = {
|
||||
|
|
|
@ -44,8 +44,7 @@ const handleRequest = function* handleRequest({ data }) {
|
|||
broadcast,
|
||||
encrypted
|
||||
} = data;
|
||||
// TODO: Create event CT_CREATE
|
||||
logEvent(events.CR_CREATE, {
|
||||
logEvent(events.CT_CREATE, {
|
||||
type,
|
||||
readOnly,
|
||||
broadcast,
|
||||
|
@ -74,7 +73,7 @@ const handleRequest = function* handleRequest({ data }) {
|
|||
sub = yield call(createChannel, data);
|
||||
|
||||
if (data.teamId) {
|
||||
// TODO: Log when adding room to team
|
||||
logEvent(events.CT_ADD_ROOM_TO_TEAM);
|
||||
const channels = yield call(addTeamRoom, { rooms: sub.rid, teamId: data.teamId });
|
||||
if (channels.success) {
|
||||
sub.teamId = channels.rooms[0].teamId;
|
||||
|
|
|
@ -101,12 +101,16 @@ export default {
|
|||
|
||||
// CREATE CHANNEL VIEW
|
||||
CR_CREATE: 'cr_create',
|
||||
CT_CREATE: 'ct_create',
|
||||
CR_CREATE_F: 'cr_create_f',
|
||||
CT_CREATE_F: 'ct_create_f',
|
||||
CR_TOGGLE_TYPE: 'cr_toggle_type',
|
||||
CR_TOGGLE_READ_ONLY: 'cr_toggle_read_only',
|
||||
CR_TOGGLE_BROADCAST: 'cr_toggle_broadcast',
|
||||
CR_TOGGLE_ENCRYPTED: 'cr_toggle_encrypted',
|
||||
CR_REMOVE_USER: 'cr_remove_user',
|
||||
CT_ADD_ROOM_TO_TEAM: 'ct_add_room_to_team',
|
||||
CT_ADD_ROOM_TO_TEAM_F: 'ct_add_room_to_team_f',
|
||||
|
||||
// CREATE DISCUSSION VIEW
|
||||
CD_CREATE: 'cd_create',
|
||||
|
|
|
@ -14,7 +14,7 @@ import database from '../lib/database';
|
|||
import RocketChat from '../lib/rocketchat';
|
||||
import sharedStyles from './Styles';
|
||||
import I18n from '../i18n';
|
||||
import log from '../utils/log';
|
||||
import log, { events, logEvent } from '../utils/log';
|
||||
import SearchBox from '../containers/SearchBox';
|
||||
import { CustomIcon } from '../lib/Icons';
|
||||
import * as HeaderButton from '../containers/HeaderButton';
|
||||
|
@ -63,7 +63,8 @@ class AddExistingChannelView extends React.Component {
|
|||
token: PropTypes.string
|
||||
}),
|
||||
theme: PropTypes.string,
|
||||
isMasterDetail: PropTypes.bool
|
||||
isMasterDetail: PropTypes.bool,
|
||||
addTeamChannelPermission: PropTypes.array
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
|
@ -107,17 +108,24 @@ class AddExistingChannelView extends React.Component {
|
|||
// eslint-disable-next-line react/sort-comp
|
||||
init = async() => {
|
||||
try {
|
||||
const { addTeamChannelPermission } = this.props;
|
||||
const db = database.active;
|
||||
const channels = await db.collections
|
||||
.get('subscriptions')
|
||||
.query(
|
||||
Q.where('t', 'p'),
|
||||
Q.where('team_id', ''),
|
||||
Q.and(Q.where('team_id', ''), Q.or(Q.where('t', 'c'), Q.where('t', 'p'))),
|
||||
Q.experimentalTake(QUERY_SIZE),
|
||||
Q.experimentalSortBy('room_updated_at', Q.desc)
|
||||
)
|
||||
.fetch();
|
||||
this.setState({ channels });
|
||||
const filteredChannels = channels.filter(async(channel) => {
|
||||
const permissions = await RocketChat.hasPermission([addTeamChannelPermission], channel.rid);
|
||||
if (!permissions[0]) {
|
||||
return;
|
||||
}
|
||||
return channel;
|
||||
});
|
||||
this.setState({ channels: filteredChannels });
|
||||
} catch (e) {
|
||||
log(e);
|
||||
}
|
||||
|
@ -145,14 +153,14 @@ class AddExistingChannelView extends React.Component {
|
|||
|
||||
this.setState({ loading: true });
|
||||
try {
|
||||
// TODO: Log request
|
||||
logEvent(events.CT_ADD_ROOM_TO_TEAM);
|
||||
const result = await RocketChat.addTeamRooms({ rooms: selected, teamId: this.teamId });
|
||||
if (result.success) {
|
||||
this.setState({ loading: false });
|
||||
goRoom({ item: result, isMasterDetail });
|
||||
}
|
||||
} catch (e) {
|
||||
// TODO: Log error
|
||||
logEvent(events.CT_ADD_ROOM_TO_TEAM_F);
|
||||
this.setState({ loading: false });
|
||||
}
|
||||
}
|
||||
|
@ -250,7 +258,8 @@ class AddExistingChannelView extends React.Component {
|
|||
}
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
isMasterDetail: state.app.isMasterDetail
|
||||
isMasterDetail: state.app.isMasterDetail,
|
||||
addTeamChannelPermission: state.permissions['add-team-channel']
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps, null)(withTheme(AddExistingChannelView));
|
||||
|
|
Loading…
Reference in New Issue