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

      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

        1. chat.png
          chat.png
          9 kB
        2. messedTime.png
          messedTime.png
          14 kB

          Issue Links

            Activity

              People

              Assignee:
              lu.liu Lu Liu
              Reporter:
              michael.chen Michael Chen (Inactive)
              Participants of an Issue:
              Recent user:
              Marta Elicegui
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                8 years, 31 weeks ago

                  Packages

                  Version Package
                  6.1.X EE
                  6.2.X EE