[FIX] Room view header crashes when destructuring reducer (#523)

This commit is contained in:
Diego Mello 2018-11-05 10:00:58 -02:00 committed by GitHub
parent 1c9aa9bf33
commit 461f865656
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 12 deletions

View File

@ -53,27 +53,33 @@ const styles = StyleSheet.create({
@connect((state) => {
let status = '';
let title = '';
if (state.room.t === 'd') {
const { id: loggedUserId } = state.login.user;
const userId = state.room.rid.replace(loggedUserId, '').trim();
if (userId === loggedUserId) {
status = state.login.user.status; // eslint-disable-line
} else {
const user = state.activeUsers[userId];
status = (user && user.status) || 'offline';
const roomType = state.room.t;
if (roomType === 'd') {
if (state.login.user && state.login.user.id) {
const { id: loggedUserId } = state.login.user;
const userId = state.room.rid.replace(loggedUserId, '').trim();
if (userId === loggedUserId) {
status = state.login.user.status; // eslint-disable-line
} else {
const user = state.activeUsers[userId];
status = (user && user.status) || 'offline';
}
}
title = state.settings.UI_Use_Real_Name ? state.room.fname : state.room.name;
} else {
title = state.room.name;
}
const { username } = state.login.user;
const { usersTyping } = state.room;
const otherUsersTyping = usersTyping.filter(_username => _username !== username);
let otherUsersTyping = [];
if (state.login.user && state.login.user.username) {
const { username } = state.login.user;
const { usersTyping } = state.room;
otherUsersTyping = usersTyping.filter(_username => _username !== username);
}
return {
usersTyping: otherUsersTyping,
type: state.room.t,
type: roomType,
title,
status
};