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