The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/client/startup/startup.js

72 lines
1.8 KiB

import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { Session } from 'meteor/session';
import { TimeSync } from 'meteor/mizzao:timesync';
import { UserPresence } from 'meteor/konecty:user-presence';
import { fireGlobalEvent } from 'meteor/rocketchat:ui-utils';
import { settings } from 'meteor/rocketchat:settings';
import { Users } from 'meteor/rocketchat:models';
import { getUserPreference } from 'meteor/rocketchat:utils';
import toastr from 'toastr';
import hljs from 'highlight.js';
import 'highlight.js/styles/github.css';
hljs.initHighlightingOnLoad();
if (window.DISABLE_ANIMATION) {
toastr.options.timeOut = 1;
toastr.options.showDuration = 0;
toastr.options.hideDuration = 0;
toastr.options.extendedTimeOut = 0;
}
Meteor.startup(function() {
TimeSync.loggingEnabled = false;
Session.setDefault('AvatarRandom', 0);
window.lastMessageWindow = {};
window.lastMessageWindowHistory = {};
Tracker.autorun(function(computation) {
if (!Meteor.userId() && !settings.get('Accounts_AllowAnonymousRead')) {
return;
}
Meteor.subscribe('userData');
Meteor.subscribe('activeUsers');
computation.stop();
});
let status = undefined;
Tracker.autorun(function() {
if (!Meteor.userId()) {
return;
}
const user = Users.findOne(Meteor.userId(), {
fields: {
status: 1,
'settings.preferences.idleTimeLimit': 1,
'settings.preferences.enableAutoAway': 1,
},
});
if (!user) {
return;
}
if (getUserPreference(user, 'enableAutoAway')) {
const idleTimeLimit = getUserPreference(user, 'idleTimeLimit') || 300;
UserPresence.awayTime = idleTimeLimit * 1000;
} else {
delete UserPresence.awayTime;
UserPresence.stopTimer();
}
UserPresence.start();
if (user.status !== status) {
status = user.status;
fireGlobalEvent('status-changed', status);
}
});
});