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] 404 error when creating direct room for the first time #22944

Merged
merged 3 commits into from
Aug 18, 2021
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
2 changes: 1 addition & 1 deletion app/e2e/client/rocketchat.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { call } from '../../ui-utils';
import './events.js';
import './tabbar';
import { log, logError } from './logger';
import { waitUntilFind } from './waitUntilFind';
import { waitUntilFind } from '../../utils/client/lib/waitUntilFind';
import { imperativeModal } from '../../../client/lib/imperativeModal';
import SaveE2EPasswordModal from './SaveE2EPasswordModal';
import EnterE2EPasswordModal from './EnterE2EPasswordModal';
Expand Down
12 changes: 0 additions & 12 deletions app/ui-utils/client/lib/openRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,6 @@ window.currentTracker = undefined;
// cleanup session when hot reloading
Session.set('openedRoom', null);


export const waitUntilRoomBeInserted = async (type, rid) => new Promise((resolve) => {
Tracker.autorun((c) => {
const room = roomTypes.findRoom(type, rid, Meteor.user());
if (room) {
c.stop();
return resolve(room);
}
});
});


NewRoomManager.on('changed', (rid) => {
Session.set('openedRoom', rid);
RoomManager.openedRoom = rid;
Expand Down
1 change: 1 addition & 0 deletions app/utils/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ export { templateVarHandler } from '../lib/templateVarHandler';
export { APIClient, mountArrayQueryParameters } from './lib/RestApiClient';
export { canDeleteMessage } from './lib/canDeleteMessage';
export { secondsToHHMMSS } from '../lib/timeConverter';
export { waitUntilFind } from './lib/waitUntilFind';
File renamed without changes.
4 changes: 3 additions & 1 deletion client/lib/goToRoomById.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ export const goToRoomById = async (rid: IRoom['_id']): Promise<void> => {
if (!rid) {
return;
}

const subscription = ChatSubscription.findOne({ rid });

if (subscription) {
roomTypes.openRouteLink(subscription.t, subscription, FlowRouter.current().queryParams);
return;
}

const room = await getRoomById(rid);
roomTypes.openRouteLink(room.t, room, FlowRouter.current().queryParams);
roomTypes.openRouteLink(room.t, { rid: room._id, ...room }, FlowRouter.current().queryParams);
};
2 changes: 1 addition & 1 deletion client/startup/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';

import { e2e } from '../../app/e2e/client/rocketchat.e2e';
import { waitUntilFind } from '../../app/e2e/client/waitUntilFind';
import { Subscriptions, Rooms } from '../../app/models/client';
import { Notifications } from '../../app/notifications/client';
import { promises } from '../../app/promises/client';
import { settings } from '../../app/settings/client';
import { Layout } from '../../app/ui-utils/client';
import { waitUntilFind } from '../../app/utils/client';
import { IMessage } from '../../definition/IMessage';
import { IRoom } from '../../definition/IRoom';
import { ISubscription } from '../../definition/ISubscription';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const RoomMembers = ({
renderRow: Row = DefaultRow,
rid,
isTeam,
isDirect,
reload,
}) => {
const t = useTranslation();
Expand Down Expand Up @@ -130,7 +131,7 @@ const RoomMembers = ({
)}
</Box>
</VerticalBar.Content>
{(onClickInvite || onClickAdd) && (
{!isDirect && (onClickInvite || onClickAdd) && (
<VerticalBar.Footer>
<ButtonGroup stretch>
{onClickInvite && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const RoomMembersWithData = ({ rid }) => {
const onClickClose = useTabBarClose();
const room = useUserRoom(rid);
const isTeam = room.teamMain;
const isDirect = room.t === 'd';

room.type = room.t;
room.rid = rid;
Expand Down Expand Up @@ -100,6 +101,7 @@ const RoomMembersWithData = ({ rid }) => {
<RoomMembers
rid={rid}
isTeam={isTeam}
isDirect={isDirect}
loading={phase === AsyncStatePhase.LOADING}
type={type}
text={text}
Expand Down