[FIX] DM header blink (#2011)
This commit is contained in:
parent
46660572c3
commit
2e65a795df
|
@ -61,8 +61,15 @@ export default async function canOpenRoom({ rid, path }) {
|
||||||
|
|
||||||
if (rid) {
|
if (rid) {
|
||||||
try {
|
try {
|
||||||
await subsCollection.find(rid);
|
const room = await subsCollection.find(rid);
|
||||||
return { rid };
|
return {
|
||||||
|
rid,
|
||||||
|
t: room.t,
|
||||||
|
name: room.name,
|
||||||
|
fname: room.fname,
|
||||||
|
prid: room.prid,
|
||||||
|
uids: room.uids
|
||||||
|
};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
|
@ -812,7 +812,9 @@ const RocketChat = {
|
||||||
return this.sdk.get('rooms.info', { roomId });
|
return this.sdk.get('rooms.info', { roomId });
|
||||||
},
|
},
|
||||||
|
|
||||||
getUidDirectMessage(room, userId) {
|
getUidDirectMessage(room) {
|
||||||
|
const { id: userId } = reduxStore.getState().login.user;
|
||||||
|
|
||||||
// legacy method
|
// legacy method
|
||||||
if (!room.uids && room.rid && room.t === 'd') {
|
if (!room.uids && room.rid && room.t === 'd') {
|
||||||
return room.rid.replace(userId, '').trim();
|
return room.rid.replace(userId, '').trim();
|
||||||
|
|
|
@ -34,7 +34,12 @@ const navigate = function* navigate({ params }) {
|
||||||
const [type, name] = params.path.split('/');
|
const [type, name] = params.path.split('/');
|
||||||
if (room) {
|
if (room) {
|
||||||
yield Navigation.navigate('RoomsListView');
|
yield Navigation.navigate('RoomsListView');
|
||||||
Navigation.navigate('RoomView', { name, t: roomTypes[type], ...room });
|
Navigation.navigate('RoomView', {
|
||||||
|
name,
|
||||||
|
t: roomTypes[type],
|
||||||
|
roomUserId: RocketChat.getUidDirectMessage(room),
|
||||||
|
...room
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
yield handleInviteLink({ params });
|
yield handleInviteLink({ params });
|
||||||
|
|
|
@ -384,11 +384,10 @@ class RoomActionsView extends React.Component {
|
||||||
|
|
||||||
updateRoomMember = async() => {
|
updateRoomMember = async() => {
|
||||||
const { room } = this.state;
|
const { room } = this.state;
|
||||||
const { user } = this.props;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!RocketChat.isGroupChat(room)) {
|
if (!RocketChat.isGroupChat(room)) {
|
||||||
const roomUserId = RocketChat.getUidDirectMessage(room, user.id);
|
const roomUserId = RocketChat.getUidDirectMessage(room);
|
||||||
const result = await RocketChat.getUserInfo(roomUserId);
|
const result = await RocketChat.getUserInfo(roomUserId);
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
this.setState({ member: result.user });
|
this.setState({ member: result.user });
|
||||||
|
|
|
@ -390,10 +390,10 @@ class RoomView extends React.Component {
|
||||||
const { t } = room;
|
const { t } = room;
|
||||||
|
|
||||||
if (t === 'd' && !RocketChat.isGroupChat(room)) {
|
if (t === 'd' && !RocketChat.isGroupChat(room)) {
|
||||||
const { user, navigation } = this.props;
|
const { navigation } = this.props;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const roomUserId = RocketChat.getUidDirectMessage(room, user.id);
|
const roomUserId = RocketChat.getUidDirectMessage(room);
|
||||||
|
|
||||||
navigation.setParams({ roomUserId });
|
navigation.setParams({ roomUserId });
|
||||||
|
|
||||||
|
|
|
@ -531,10 +531,7 @@ class RoomsListView extends React.Component {
|
||||||
|
|
||||||
getUserPresence = uid => RocketChat.getUserPresence(uid)
|
getUserPresence = uid => RocketChat.getUserPresence(uid)
|
||||||
|
|
||||||
getUidDirectMessage = (room) => {
|
getUidDirectMessage = room => RocketChat.getUidDirectMessage(room);
|
||||||
const { user: { id } } = this.props;
|
|
||||||
return RocketChat.getUidDirectMessage(room, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
goRoom = (item) => {
|
goRoom = (item) => {
|
||||||
const { navigation } = this.props;
|
const { navigation } = this.props;
|
||||||
|
|
Loading…
Reference in New Issue