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

[IMPROVE] Added flag skipActiveUsersToBeReady to not wait the load of active users to present the Web interface #14431

Merged
merged 3 commits into from
May 8, 2019
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
25 changes: 18 additions & 7 deletions app/ui-master/client/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import { Match } from 'meteor/check';
import { Tracker } from 'meteor/tracker';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { t, getUserPreference } from '../../utils';
import { getConfig } from '../../ui-utils/client/config';
import { Session } from 'meteor/session';
import { Template } from 'meteor/templating';
import { chatMessages } from '../../ui';
import { mainReady, Layout, iframeLogin, modal, popover, menu, fireGlobalEvent, RoomManager } from '../../ui-utils';
import { toolbarSearch } from '../../ui-sidenav';
import { settings } from '../../settings';
import { CachedChatSubscription, Roles, ChatSubscription } from '../../models';
import { CachedChatSubscription, Roles, ChatSubscription, Users } from '../../models';
import { CachedCollectionManager } from '../../ui-cached-collection';
import { hasRole } from '../../authorization';
import { tooltip } from '../../tooltip';
Expand Down Expand Up @@ -131,6 +132,8 @@ Template.main.onCreated(function() {
tooltip.init();
});


const skipActiveUsersToBeReady = [getConfig('experimental'), getConfig('skipActiveUsersToBeReady')].includes('true');
Template.main.helpers({
removeSidenav() {
return Layout.isEmbedded() && !/^\/admin/.test(FlowRouter.current().route.path);
Expand All @@ -156,18 +159,26 @@ Template.main.helpers({
return iframeEnabled && iframeLogin.reactiveIframeUrl.get();
},
subsReady() {
const routerReady = FlowRouter.subsReady('userData', 'activeUsers');
const subscriptions = ['userData'];
if (!skipActiveUsersToBeReady) {
subscriptions.push('activeUsers');
}
const routerReady = FlowRouter.subsReady.apply(FlowRouter, subscriptions);

const subscriptionsReady = CachedChatSubscription.ready.get();
const settingsReady = settings.cachedCollection.ready.get();
const ready = (Meteor.userId() == null) || (routerReady && subscriptionsReady && settingsReady);

const ready = (routerReady && subscriptionsReady && settingsReady) || !Meteor.userId();

CachedCollectionManager.syncEnabled = ready;
Meteor.defer(() => {
mainReady.set(ready);
});
mainReady.set(ready);

return ready;
},
hasUsername() {
return (Meteor.userId() != null && Meteor.user().username != null) || (Meteor.userId() == null && settings.get('Accounts_AllowAnonymousRead') === true);
const uid = Meteor.userId();
const user = uid && Users.findOne({ _id: uid }, { fields: { username: 1 } });
return (user && user.username) || settings.get('Accounts_AllowAnonymousRead');
},
requirePasswordChange() {
const user = Meteor.user();
Expand Down