MDL-65657 message: revert polling timeout back to old algorithm
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -110,7 +110,7 @@ function(
|
||||
|
||||
var NEWEST_FIRST = Constants.NEWEST_MESSAGES_FIRST;
|
||||
var LOAD_MESSAGE_LIMIT = Constants.LOAD_MESSAGE_LIMIT;
|
||||
var INITIAL_NEW_MESSAGE_POLL_TIMEOUT = Constants.INITIAL_NEW_MESSAGE_POLL_TIMEOUT;
|
||||
var MILLISECONDS_IN_SEC = Constants.MILLISECONDS_IN_SEC;
|
||||
var SELECTORS = Constants.SELECTORS;
|
||||
var CONVERSATION_TYPES = Constants.CONVERSATION_TYPES;
|
||||
|
||||
@@ -1477,13 +1477,12 @@ function(
|
||||
|
||||
newMessagesPollTimer = new BackOffTimer(
|
||||
getLoadNewMessagesCallback(conversationId, NEWEST_FIRST),
|
||||
function(time) {
|
||||
if (!time) {
|
||||
return INITIAL_NEW_MESSAGE_POLL_TIMEOUT;
|
||||
}
|
||||
|
||||
return time * 2;
|
||||
}
|
||||
BackOffTimer.getIncrementalCallback(
|
||||
viewState.messagePollMin * MILLISECONDS_IN_SEC,
|
||||
MILLISECONDS_IN_SEC,
|
||||
viewState.messagePollMax * MILLISECONDS_IN_SEC,
|
||||
viewState.messagePollAfterMax * MILLISECONDS_IN_SEC
|
||||
)
|
||||
);
|
||||
|
||||
newMessagesPollTimer.start();
|
||||
@@ -1500,7 +1499,17 @@ function(
|
||||
var resetState = function(body, conversationId, loggedInUserProfile) {
|
||||
var loggedInUserId = loggedInUserProfile.id;
|
||||
var midnight = parseInt(body.attr('data-midnight'), 10);
|
||||
var initialState = StateManager.buildInitialState(midnight, loggedInUserId, conversationId);
|
||||
var messagePollMin = parseInt(body.attr('data-message-poll-min'), 10);
|
||||
var messagePollMax = parseInt(body.attr('data-message-poll-max'), 10);
|
||||
var messagePollAfterMax = parseInt(body.attr('data-message-poll-after-max'), 10);
|
||||
var initialState = StateManager.buildInitialState(
|
||||
midnight,
|
||||
loggedInUserId,
|
||||
conversationId,
|
||||
messagePollMin,
|
||||
messagePollMax,
|
||||
messagePollAfterMax
|
||||
);
|
||||
|
||||
if (!viewState) {
|
||||
viewState = initialState;
|
||||
|
||||
@@ -110,6 +110,6 @@ define([], function() {
|
||||
CONVERSATION_TYPES: CONVERSATION_TYPES,
|
||||
NEWEST_MESSAGES_FIRST: true,
|
||||
LOAD_MESSAGE_LIMIT: 100,
|
||||
INITIAL_NEW_MESSAGE_POLL_TIMEOUT: 1000
|
||||
MILLISECONDS_IN_SEC: 1000
|
||||
};
|
||||
});
|
||||
|
||||
@@ -101,13 +101,26 @@ define(['jquery'], function($) {
|
||||
* @param {Number} midnight Midnight time.
|
||||
* @param {Number} loggedInUserId The logged in user id.
|
||||
* @param {Number} id The conversation id.
|
||||
* @param {Number} messagePollMin The message poll start timeout in seconds.
|
||||
* @param {Number} messagePollMax The message poll max timeout limit in seconds.
|
||||
* @param {Number} messagePollAfterMax The message poll frequency in seconds to reset to after max limit is reached.
|
||||
* @return {Object} Initial state.
|
||||
*/
|
||||
var buildInitialState = function(midnight, loggedInUserId, id) {
|
||||
var buildInitialState = function(
|
||||
midnight,
|
||||
loggedInUserId,
|
||||
id,
|
||||
messagePollMin,
|
||||
messagePollMax,
|
||||
messagePollAfterMax
|
||||
) {
|
||||
return {
|
||||
midnight: midnight,
|
||||
loggedInUserId: loggedInUserId,
|
||||
id: id,
|
||||
messagePollMin: messagePollMin,
|
||||
messagePollMax: messagePollMax,
|
||||
messagePollAfterMax: messagePollAfterMax,
|
||||
name: null,
|
||||
subname: null,
|
||||
type: null,
|
||||
|
||||
@@ -26,6 +26,8 @@ namespace core_message;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->dirroot . '/message/lib.php');
|
||||
|
||||
/**
|
||||
* Helper class for the message area.
|
||||
*
|
||||
@@ -741,6 +743,12 @@ class helper {
|
||||
'id' => $USER->id,
|
||||
'midnight' => usergetmidnight(time())
|
||||
],
|
||||
// The starting timeout value for message polling.
|
||||
'messagepollmin' => $CFG->messagingminpoll ?? MESSAGE_DEFAULT_MIN_POLL_IN_SECONDS,
|
||||
// The maximum value that message polling timeout can reach.
|
||||
'messagepollmax' => $CFG->messagingmaxpoll ?? MESSAGE_DEFAULT_MAX_POLL_IN_SECONDS,
|
||||
// The timeout to reset back to after the max polling time has been reached.
|
||||
'messagepollaftermax' => $CFG->messagingtimeoutpoll ?? MESSAGE_DEFAULT_TIMEOUT_POLL_IN_SECONDS,
|
||||
'contacts' => [
|
||||
'sectioncontacts' => [
|
||||
'placeholders' => array_fill(0, $contactscount > 50 ? 50 : $contactscount, true)
|
||||
|
||||
@@ -40,6 +40,9 @@
|
||||
data-region="view-conversation"
|
||||
data-user-id="{{loggedinuser.id}}"
|
||||
data-midnight="{{loggedinuser.midnight}}"
|
||||
data-message-poll-min="{{messagepollmin}}"
|
||||
data-message-poll-max="{{messagepollmax}}"
|
||||
data-message-poll-after-max="{{messagepollaftermax}}"
|
||||
style="overflow-y: auto; overflow-x: hidden"
|
||||
>
|
||||
<div class="position-relative h-100" data-region="content-container" style="overflow-y: auto; overflow-x: hidden">
|
||||
|
||||
Reference in New Issue
Block a user