Minor tweaks for removing channels and addExistingChannelView

This commit is contained in:
Gerzon Z 2021-05-05 03:46:18 -04:00
parent 69ae247329
commit 4761e21de8
7 changed files with 13 additions and 10 deletions

View File

@ -435,6 +435,7 @@
"Review_app_unable_store": "Unable to open {{store}}",
"Review_this_app": "Review this app",
"Remove": "Remove",
"remove": "remove",
"Roles": "Roles",
"Room_actions": "Room actions",
"Room_changed_announcement": "Room announcement changed to: {{announcement}} by {{userBy}}",
@ -724,5 +725,6 @@
"Remove_from_Team": "Remove from Team",
"Auto-join": "Auto-join",
"Delete_Team_Room_Warning": "Woud you like to remove this channel from the team? The channel will be moved back to the workspace",
"Confirmation": "Confirmation"
"Confirmation": "Confirmation",
"invalid-room": "Invalid room"
}

View File

@ -13,7 +13,7 @@ async function load({
if (team.type) {
apiType = this.roomTypeToApiType('p');
} else {
apiType = this.roomTypeToApiType(t);
apiType = this.roomTypeToApiType(t || 'c');
}
if (!apiType) {
return [];

View File

@ -748,7 +748,7 @@ const RocketChat = {
},
addTeamRooms({ rooms, teamId }) {
const params = {
rooms: rooms.length ? [...rooms] : [rooms],
rooms: Array.isArray(rooms) ? rooms : [rooms],
teamId
};
// RC 3.13.0

View File

@ -77,7 +77,8 @@ const handleRequest = function* handleRequest({ data }) {
// TODO: Log when adding room to team
const channels = yield call(addTeamRoom, { rooms: sub.rid, teamId: data.teamId });
if (channels.success) {
sub.teamId = channels.teamId;
sub.teamId = channels.rooms[0].teamId;
sub.isTeamChannel = true;
}
}
}

View File

@ -8,7 +8,7 @@ const navigate = ({ item, isMasterDetail, ...props }) => {
navigationMethod = Navigation.replace;
}
if (item.rooms && item.teamId) {
if (item.isTeamChannel) {
// TODO: Refactor
Navigation.navigate('TeamChannelsView');
Navigation.push('RoomView', {
@ -23,6 +23,8 @@ const navigate = ({ item, isMasterDetail, ...props }) => {
teamId: item.teamId,
...props
});
} else if (item.rooms) {
Navigation.navigate('TeamChannelsView');
} else {
navigationMethod('RoomView', {
rid: item.roomId || item.rid,

View File

@ -149,7 +149,7 @@ class AddExistingChannelView extends React.Component {
const result = await RocketChat.addTeamRooms({ rooms: selected, teamId: this.teamId });
if (result.success) {
this.setState({ loading: false });
goRoom({ result, isMasterDetail });
goRoom({ item: result, isMasterDetail });
}
} catch (e) {
// TODO: Log error

View File

@ -334,7 +334,7 @@ class TeamChannelsView extends React.Component {
style: 'cancel'
},
{
text: I18n.t('Yes_action_it', { action: I18n.t('delete') }),
text: I18n.t('Yes_action_it', { action: I18n.t('remove') }),
style: 'destructive',
onPress: () => this.removeRoom(item)
}
@ -348,12 +348,10 @@ class TeamChannelsView extends React.Component {
const { data } = this.state;
const result = await RocketChat.removeTeamRoom({ roomId: item.rid, teamId: this.team.teamId });
if (result.success) {
console.log({ result });
const newData = data.filter(room => result.room._id !== room.rid);
console.log({ newData });
this.setState({ loading: true, data: newData }, () => {
this.loadTeam();
this.load();
this.loadTeam();
});
}
} catch (e) {