Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-42480

Chat Portlet - message display time sometimes exceeds current system time

    Details

    • Branch Version/s:
      6.2.x, 6.1.x
    • Backported to Branch:
      Committed
    • Story Points:
      4
    • Fix Priority:
      4

      Description

      While two users are chatting, the received message display time in chat box sometimes exceeds the current system time.

      Steps to reproduce :
      1) Deploy chat portlet into portal
      2) Create 2 users - user1 and user2
      3) Open 2 browsers and log in with each of them
      4) Start chatting

      Actual Behavior:
      Sometimes we'll see the received message display time exceeds the current system time (See attached screenshot, you also see the seconds is because I did that for debugging)
      PS : The issue is easier to replicate while sending message by the end of a minute

      Expected Behavior:
      The message display time should not exceed current system time, it shows the current time at most

      The root cause is that when a user logs in and starts a chat, an offset will be calculated and set. This offset can be several seconds to even minutes.

      _getOffset: function() {
      	var instance = this;
      
      	var offset = instance._offset;
      
      	if (Lang.isUndefined(offset)) {
      		var currentChatServerTime = A.one('#currentChatServerTime').val() || now();
      
      		offset = now() - currentChatServerTime;
      
      		instance._offset = offset;
      	}
      
      	return offset;
      },
      

      When converting to client timestamp, the display time is added by the offset. Sometimes this could exceed current system time.

      _convertToClientTimestamp: function(time) {
      	var instance = this;
      
      	time = Number(time);
      
      	time += instance._getOffset();
      
      	return time;
      },
      

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  3 years, 24 weeks ago

                  Subcomponents