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] Not redirecting to First Channel After Login on register #17664

Merged
merged 2 commits into from
May 16, 2020
Merged
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
28 changes: 22 additions & 6 deletions app/ui-sidenav/client/sideNav.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { ReactiveVar } from 'meteor/reactive-var';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Template } from 'meteor/templating';
Expand Down Expand Up @@ -79,13 +80,28 @@ Template.sideNav.events({
});

const redirectToDefaultChannelIfNeeded = () => {
const currentRouteState = FlowRouter.current();
const needToBeRedirect = ['/', '/home'];
const firstChannelAfterLogin = settings.get('First_Channel_After_Login');
const room = roomTypes.findRoom('c', firstChannelAfterLogin, Meteor.userId());
if (room && room._id && needToBeRedirect.includes(currentRouteState.path)) {
const needToBeRedirect = () => ['/', '/home'].includes(FlowRouter.current().path);

Tracker.autorun((c) => {
const firstChannelAfterLogin = settings.get('First_Channel_After_Login');

if (!needToBeRedirect()) {
return c.stop();
}

if (!firstChannelAfterLogin) {
return c.stop();
}

const room = roomTypes.findRoom('c', firstChannelAfterLogin, Meteor.userId());

if (!room) {
return;
}

c.stop();
FlowRouter.go(`/channel/${ firstChannelAfterLogin }`);
}
});
};

Template.sideNav.onRendered(function() {
Expand Down