Преглед на файлове

Fixes chat messages timestamp according to XEP-0203. Fixes #305.

j8
Zalmoxisus преди 10 години
родител
ревизия
7a54537bee
променени са 4 файла, в които са добавени 10 реда и са изтрити 10 реда
  1. 2
    2
      modules/API/API.js
  2. 3
    3
      modules/UI/UI.js
  3. 4
    4
      modules/UI/side_pannels/chat/Chat.js
  4. 1
    1
      modules/xmpp/strophe.emuc.js

+ 2
- 2
modules/API/API.js Целия файл

@@ -138,10 +138,10 @@ function setupListeners() {
138 138
     APP.xmpp.addListener(XMPPEvents.MUC_MEMBER_JOINED, function (from) {
139 139
         API.triggerEvent("participantJoined", {jid: from});
140 140
     });
141
-    APP.xmpp.addListener(XMPPEvents.MESSAGE_RECEIVED, function (from, nick, txt, myjid) {
141
+    APP.xmpp.addListener(XMPPEvents.MESSAGE_RECEIVED, function (from, nick, txt, myjid, stamp) {
142 142
         if (from != myjid)
143 143
             API.triggerEvent("incomingMessage",
144
-                {"from": from, "nick": nick, "message": txt});
144
+                {"from": from, "nick": nick, "message": txt, "stamp": stamp});
145 145
     });
146 146
     APP.xmpp.addListener(XMPPEvents.MUC_MEMBER_LEFT, function (jid) {
147 147
         API.triggerEvent("participantLeft", {jid: jid});

+ 3
- 3
modules/UI/UI.js Целия файл

@@ -408,9 +408,9 @@ function chatSetSubject(text)
408 408
     return Chat.chatSetSubject(text);
409 409
 };
410 410
 
411
-function updateChatConversation(from, displayName, message) {
412
-    return Chat.updateChatConversation(from, displayName, message);
413
-};
411
+function updateChatConversation(from, displayName, message, myjid, stamp) {
412
+    return Chat.updateChatConversation(from, displayName, message, myjid, stamp);
413
+}
414 414
 
415 415
 function onMucJoined(jid, info) {
416 416
     Toolbar.updateRoomUrl(window.location.href);

+ 4
- 4
modules/UI/side_pannels/chat/Chat.js Целия файл

@@ -85,8 +85,8 @@ function setVisualNotification(show) {
85 85
  * Returns the current time in the format it is shown to the user
86 86
  * @returns {string}
87 87
  */
88
-function getCurrentTime() {
89
-    var now     = new Date();
88
+function getCurrentTime(stamp) {
89
+    var now     = (stamp? new Date(stamp): new Date());
90 90
     var hour    = now.getHours();
91 91
     var minute  = now.getMinutes();
92 92
     var second  = now.getSeconds();
@@ -228,7 +228,7 @@ var Chat = (function (my) {
228 228
     /**
229 229
      * Appends the given message to the chat conversation.
230 230
      */
231
-    my.updateChatConversation = function (from, displayName, message) {
231
+    my.updateChatConversation = function (from, displayName, message, myjid, stamp) {
232 232
         var divClassName = '';
233 233
 
234 234
         if (APP.xmpp.myJid() === from) {
@@ -256,7 +256,7 @@ var Chat = (function (my) {
256 256
             '<div class="chatmessage">'+
257 257
                 '<img src="../images/chatArrow.svg" class="chatArrow">' +
258 258
                 '<div class="username ' + divClassName +'">' + escDisplayName +
259
-                '</div>' + '<div class="timestamp">' + getCurrentTime() +
259
+                '</div>' + '<div class="timestamp">' + getCurrentTime(stamp) +
260 260
                 '</div>' + '<div class="usermessage">' + message + '</div>' +
261 261
             '</div>';
262 262
 

+ 1
- 1
modules/xmpp/strophe.emuc.js Целия файл

@@ -389,7 +389,7 @@ module.exports = function(XMPP, eventEmitter) {
389 389
             if (txt) {
390 390
                 console.log('chat', nick, txt);
391 391
                 eventEmitter.emit(XMPPEvents.MESSAGE_RECEIVED,
392
-                    from, nick, txt, this.myroomjid);
392
+                    from, nick, txt, this.myroomjid, $(msg).find('>delay').attr('stamp'));
393 393
             }
394 394
             return true;
395 395
         },

Loading…
Отказ
Запис