Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Respect UI_Allow_room_names_with_special_chars setting #2076

Merged
merged 2 commits into from
Apr 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/constants/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ export default {
uniqueID: {
type: 'valueAsString'
},
UI_Allow_room_names_with_special_chars: {
type: 'valueAsBoolean'
},
UI_Use_Real_Name: {
type: 'valueAsBoolean'
},
Expand Down
5 changes: 4 additions & 1 deletion app/lib/rocketchat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions app/views/RoomActionsView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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>
)
}
Expand Down
4 changes: 2 additions & 2 deletions app/views/RoomInfoEditView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion app/views/RoomInfoView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>
)
);
Expand Down
13 changes: 4 additions & 9 deletions app/views/RoomView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) });
}
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'));
}
}

Expand All @@ -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) {
Expand Down