[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,7 +53,9 @@ 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;
if (roomType === 'd') {
if (state.login.user && state.login.user.id) {
const { id: loggedUserId } = state.login.user; const { id: loggedUserId } = state.login.user;
const userId = state.room.rid.replace(loggedUserId, '').trim(); const userId = state.room.rid.replace(loggedUserId, '').trim();
if (userId === loggedUserId) { if (userId === loggedUserId) {
@ -62,18 +64,22 @@ const styles = StyleSheet.create({
const user = state.activeUsers[userId]; const user = state.activeUsers[userId];
status = (user && user.status) || 'offline'; 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;
} }
let otherUsersTyping = [];
if (state.login.user && state.login.user.username) {
const { username } = state.login.user; const { username } = state.login.user;
const { usersTyping } = state.room; const { usersTyping } = state.room;
const otherUsersTyping = usersTyping.filter(_username => _username !== username); otherUsersTyping = usersTyping.filter(_username => _username !== username);
}
return { return {
usersTyping: otherUsersTyping, usersTyping: otherUsersTyping,
type: state.room.t, type: roomType,
title, title,
status status
}; };