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