Skip to content

Commit

Permalink
[FIX] "Idle Time Limit" using milliseconds instead of seconds (#9824)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiiiiiiiii authored and graywolf336 committed Apr 18, 2018
1 parent 62f6b77 commit 6fe8e11
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 6 deletions.
6 changes: 3 additions & 3 deletions client/startup/startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,17 @@ Meteor.startup(function() {
}
};

const defaultIdleTimeLimit = 300000;
const defaultIdleTimeLimit = 300;

Meteor.subscribe('userData', function() {
const user = Meteor.user();
const userLanguage = user && user.language ? user.language : window.defaultUserLanguage();

if (!userHasPreferences(user)) {
UserPresence.awayTime = defaultIdleTimeLimit;
UserPresence.awayTime = defaultIdleTimeLimit * 1000;
UserPresence.start();
} else {
UserPresence.awayTime = user.settings.preferences.idleTimeLimit || defaultIdleTimeLimit;
UserPresence.awayTime = (user.settings.preferences.idleTimeLimit || defaultIdleTimeLimit) * 1000;

if (user.settings.preferences.hasOwnProperty('enableAutoAway')) {
user.settings.preferences.enableAutoAway && UserPresence.start();
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,7 @@
"IssueLinks_LinkTemplate_Description": "Template for issue links; %s will be replaced by the issue number.",
"It_works": "It works",
"Idle_Time_Limit": "Idle Time Limit",
"Idle_Time_Limit_Description": "Period of time until status changes to away. Value needs to be in seconds.",
"italics": "italics",
"Jitsi_Chrome_Extension": "Chrome Extension Id",
"Jitsi_Enable_Channels": "Enable in Channels",
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-lib/server/startup/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ RocketChat.settings.addGroup('Accounts', function() {
'public': true,
i18nLabel: 'Enable_Auto_Away'
});
this.add('Accounts_Default_User_Preferences_idleTimeoutLimit', 300000, {
this.add('Accounts_Default_User_Preferences_idleTimeoutLimit', 300, {
type: 'int',
'public': true,
i18nLabel: 'Idle_Time_Limit'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ <h1>{{_ "User_Presence"}}</h1>
{{else}}
<input type="number" class="rc-input__element" name="idleTimeLimit" min="0" value="" placeholder="{{_ "Use_Global_Settings"}} ({{defaultIdleTimeLimit}})">
{{/if}}
<div class="info">{{_ "Idle_Time_Limit_Description"}}</div>
</div>
</div>
</div>
Expand Down
25 changes: 25 additions & 0 deletions server/startup/migrations/v112.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
RocketChat.Migrations.add({
version: 112,
up() {
if (RocketChat && RocketChat.models) {
if (RocketChat.models.Settings) {
const setting = RocketChat.models.Settings.findOne({ _id: 'Accounts_Default_User_Preferences_idleTimeoutLimit' });
if (setting && setting.value) {
RocketChat.models.Settings.update(
{ _id: 'Accounts_Default_User_Preferences_idleTimeoutLimit' },
{ $set: { value: setting.value / 1000 } }
);
}
}

if (RocketChat.models.Users) {
RocketChat.models.Users.find({ 'settings.preferences.idleTimeLimit': { $exists: 1 } }).forEach(function(user) {
RocketChat.models.Users.update(
{ _id: user._id },
{ $set: { 'settings.preferences.idleTimeLimit': user.settings.preferences.idleTimeLimit / 1000 } }
);
});
}
}
}
});
4 changes: 2 additions & 2 deletions tests/end-to-end/ui/11-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -739,8 +739,8 @@ describe('[Administration]', () => {
admin.accountsIdleTimeoutLimit.click();
admin.accountsIdleTimeoutLimit.isVisible().should.be.true;
});
it('the idle timeout limit field value should be 0', () => {
admin.accountsIdleTimeoutLimit.getValue().should.equal('300000');
it('the idle timeout limit field value should be 300', () => {
admin.accountsIdleTimeoutLimit.getValue().should.equal('300');
});

it('it should show the notifications durations field', () => {
Expand Down

0 comments on commit 6fe8e11

Please sign in to comment.