[FIX] Respect UI_Allow_room_names_with_special_chars setting (#2076)
Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
parent
8201602291
commit
200f94e244
|
@ -125,6 +125,9 @@ export default {
|
||||||
uniqueID: {
|
uniqueID: {
|
||||||
type: 'valueAsString'
|
type: 'valueAsString'
|
||||||
},
|
},
|
||||||
|
UI_Allow_room_names_with_special_chars: {
|
||||||
|
type: 'valueAsBoolean'
|
||||||
|
},
|
||||||
UI_Use_Real_Name: {
|
UI_Use_Real_Name: {
|
||||||
type: 'valueAsBoolean'
|
type: 'valueAsBoolean'
|
||||||
},
|
},
|
||||||
|
|
|
@ -1226,11 +1226,14 @@ const RocketChat = {
|
||||||
return this.methodCall('autoTranslate.translateMessage', message, targetLanguage);
|
return this.methodCall('autoTranslate.translateMessage', message, targetLanguage);
|
||||||
},
|
},
|
||||||
getRoomTitle(room) {
|
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;
|
const { username } = reduxStore.getState().login.user;
|
||||||
if (RocketChat.isGroupChat(room) && !(room.name && room.name.length)) {
|
if (RocketChat.isGroupChat(room) && !(room.name && room.name.length)) {
|
||||||
return room.usernames.filter(u => u !== username).sort((u1, u2) => u1.localeCompare(u2)).join(', ');
|
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;
|
return ((room.prid || useRealName) && room.fname) || room.name;
|
||||||
},
|
},
|
||||||
getRoomAvatar(room) {
|
getRoomAvatar(room) {
|
||||||
|
|
|
@ -442,7 +442,7 @@ class RoomActionsView extends React.Component {
|
||||||
|
|
||||||
Alert.alert(
|
Alert.alert(
|
||||||
I18n.t('Are_you_sure_question_mark'),
|
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'),
|
text: I18n.t('Cancel'),
|
||||||
|
@ -484,7 +484,7 @@ class RoomActionsView extends React.Component {
|
||||||
: (
|
: (
|
||||||
<View style={styles.roomTitleRow}>
|
<View style={styles.roomTitleRow}>
|
||||||
<RoomTypeIcon type={room.prid ? 'discussion' : room.t} theme={theme} />
|
<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>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,13 +125,13 @@ class RoomInfoEditView extends React.Component {
|
||||||
|
|
||||||
init = (room) => {
|
init = (room) => {
|
||||||
const {
|
const {
|
||||||
name, description, topic, announcement, t, ro, reactWhenReadOnly, joinCodeRequired, sysMes
|
description, topic, announcement, t, ro, reactWhenReadOnly, joinCodeRequired, sysMes
|
||||||
} = room;
|
} = room;
|
||||||
// fake password just to user knows about it
|
// fake password just to user knows about it
|
||||||
this.randomValue = random(15);
|
this.randomValue = random(15);
|
||||||
this.setState({
|
this.setState({
|
||||||
room,
|
room,
|
||||||
name,
|
name: RocketChat.getRoomTitle(room),
|
||||||
description,
|
description,
|
||||||
topic,
|
topic,
|
||||||
announcement,
|
announcement,
|
||||||
|
|
|
@ -36,7 +36,7 @@ const getRoomTitle = (room, type, name, username, statusText, theme) => (type ==
|
||||||
: (
|
: (
|
||||||
<View style={styles.roomTitleRow}>
|
<View style={styles.roomTitleRow}>
|
||||||
<RoomTypeIcon type={room.prid ? 'discussion' : room.t} key='room-info-type' theme={theme} />
|
<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>
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -218,7 +218,7 @@ class RoomView extends React.Component {
|
||||||
} = this.props;
|
} = this.props;
|
||||||
if ((room.id || room.rid) && !this.tmid) {
|
if ((room.id || room.rid) && !this.tmid) {
|
||||||
navigation.setParams({
|
navigation.setParams({
|
||||||
name: this.getRoomTitle(room),
|
name: RocketChat.getRoomTitle(room),
|
||||||
subtitle: room.topic,
|
subtitle: room.topic,
|
||||||
avatar: room.name,
|
avatar: room.name,
|
||||||
t: room.t,
|
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) {
|
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 });
|
this.setState({ room });
|
||||||
if (!this.tmid) {
|
if (!this.tmid) {
|
||||||
navigation.setParams({
|
navigation.setParams({
|
||||||
name: this.getRoomTitle(room),
|
name: RocketChat.getRoomTitle(room),
|
||||||
subtitle: room.topic,
|
subtitle: room.topic,
|
||||||
avatar: room.name,
|
avatar: room.name,
|
||||||
t: room.t
|
t: room.t
|
||||||
|
@ -645,7 +645,7 @@ class RoomView extends React.Component {
|
||||||
const { room } = this.state;
|
const { room } = this.state;
|
||||||
if (rid === this.rid) {
|
if (rid === this.rid) {
|
||||||
Navigation.navigate('RoomsListView');
|
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 = () => {
|
getMessages = () => {
|
||||||
const { room } = this.state;
|
const { room } = this.state;
|
||||||
if (room.lastOpen) {
|
if (room.lastOpen) {
|
||||||
|
|
Loading…
Reference in New Issue