[FIX] Respect UI_Allow_room_names_with_special_chars setting (#2076)

Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
Djorkaeff Alexandre 2020-04-30 13:24:49 -03:00 committed by GitHub
parent 8201602291
commit 200f94e244
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 16 additions and 15 deletions

View File

@ -125,6 +125,9 @@ export default {
uniqueID: {
type: 'valueAsString'
},
UI_Allow_room_names_with_special_chars: {
type: 'valueAsBoolean'
},
UI_Use_Real_Name: {
type: 'valueAsBoolean'
},

View File

@ -1226,11 +1226,14 @@ const RocketChat = {
return this.methodCall('autoTranslate.translateMessage', message, targetLanguage);
},
getRoomTitle(room) {
const { UI_Use_Real_Name: useRealName } = reduxStore.getState().settings;
const { UI_Use_Real_Name: useRealName, UI_Allow_room_names_with_special_chars: allowSpecialChars } = reduxStore.getState().settings;
const { username } = reduxStore.getState().login.user;
if (RocketChat.isGroupChat(room) && !(room.name && room.name.length)) {
return room.usernames.filter(u => u !== username).sort((u1, u2) => u1.localeCompare(u2)).join(', ');
}
if (allowSpecialChars && room.t !== 'd') {
return room.fname || room.name;
}
return ((room.prid || useRealName) && room.fname) || room.name;
},
getRoomAvatar(room) {

View File

@ -442,7 +442,7 @@ class RoomActionsView extends React.Component {
Alert.alert(
I18n.t('Are_you_sure_question_mark'),
I18n.t('Are_you_sure_you_want_to_leave_the_room', { room: room.t === 'd' ? room.fname : room.name }),
I18n.t('Are_you_sure_you_want_to_leave_the_room', { room: RocketChat.getRoomTitle(room) }),
[
{
text: I18n.t('Cancel'),
@ -484,7 +484,7 @@ class RoomActionsView extends React.Component {
: (
<View style={styles.roomTitleRow}>
<RoomTypeIcon type={room.prid ? 'discussion' : room.t} theme={theme} />
<Text style={[styles.roomTitle, { color: themes[theme].titleText }]} numberOfLines={1}>{room.prid ? room.fname : room.name}</Text>
<Text style={[styles.roomTitle, { color: themes[theme].titleText }]} numberOfLines={1}>{RocketChat.getRoomTitle(room)}</Text>
</View>
)
}

View File

@ -125,13 +125,13 @@ class RoomInfoEditView extends React.Component {
init = (room) => {
const {
name, description, topic, announcement, t, ro, reactWhenReadOnly, joinCodeRequired, sysMes
description, topic, announcement, t, ro, reactWhenReadOnly, joinCodeRequired, sysMes
} = room;
// fake password just to user knows about it
this.randomValue = random(15);
this.setState({
room,
name,
name: RocketChat.getRoomTitle(room),
description,
topic,
announcement,

View File

@ -36,7 +36,7 @@ const getRoomTitle = (room, type, name, username, statusText, theme) => (type ==
: (
<View style={styles.roomTitleRow}>
<RoomTypeIcon type={room.prid ? 'discussion' : room.t} key='room-info-type' theme={theme} />
<Text testID='room-info-view-name' style={[styles.roomTitle, { color: themes[theme].titleText }]} key='room-info-name'>{room.prid ? room.fname : room.name}</Text>
<Text testID='room-info-view-name' style={[styles.roomTitle, { color: themes[theme].titleText }]} key='room-info-name'>{RocketChat.getRoomTitle(room)}</Text>
</View>
)
);

View File

@ -218,7 +218,7 @@ class RoomView extends React.Component {
} = this.props;
if ((room.id || room.rid) && !this.tmid) {
navigation.setParams({
name: this.getRoomTitle(room),
name: RocketChat.getRoomTitle(room),
subtitle: room.topic,
avatar: room.name,
t: room.t,
@ -292,7 +292,7 @@ class RoomView extends React.Component {
}
}
if (((roomUpdate.fname !== prevState.roomUpdate.fname) || (roomUpdate.name !== prevState.roomUpdate.name)) && !this.tmid) {
navigation.setParams({ name: this.getRoomTitle(room) });
navigation.setParams({ name: RocketChat.getRoomTitle(room) });
}
}
@ -456,7 +456,7 @@ class RoomView extends React.Component {
this.setState({ room });
if (!this.tmid) {
navigation.setParams({
name: this.getRoomTitle(room),
name: RocketChat.getRoomTitle(room),
subtitle: room.topic,
avatar: room.name,
t: room.t
@ -645,7 +645,7 @@ class RoomView extends React.Component {
const { room } = this.state;
if (rid === this.rid) {
Navigation.navigate('RoomsListView');
showErrorAlert(I18n.t('You_were_removed_from_channel', { channel: this.getRoomTitle(room) }), I18n.t('Oops'));
showErrorAlert(I18n.t('You_were_removed_from_channel', { channel: RocketChat.getRoomTitle(room) }), I18n.t('Oops'));
}
}
@ -667,11 +667,6 @@ class RoomView extends React.Component {
});
};
getRoomTitle = (room) => {
const { useRealName } = this.props;
return ((room.prid || useRealName) && room.fname) || room.name;
}
getMessages = () => {
const { room } = this.state;
if (room.lastOpen) {