Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
FIX: Stamp tag bug on MAM
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Aguiar committed Jun 25, 2019
1 parent 59be055 commit 6e625a8
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 16 deletions.
2 changes: 1 addition & 1 deletion server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const express = require('express');
const consola = require('consola');
const { Nuxt, Builder } = require('nuxt');
const app = express();
const host = process.env.HOST || '127.0.0.1';
const host = process.env.HOST || '10.22.50.80';
const port = process.env.PORT || 3000;
const BASE_URL = process.env.BASE_URL;

Expand Down
13 changes: 10 additions & 3 deletions services/xmpp-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default {
if (setAppLoading) {
setTimeout(function() {
ctx.store.dispatch('app/updateIsAppLoading', false);
}, 1000);
}, 3000);
}
},

Expand Down Expand Up @@ -327,14 +327,21 @@ export default {
const resultId = message
.getElementsByTagName('result')[0]
.getAttribute('id');
const stamp = message.getElementsByTagName('stamp')[0].textContent;
const stamp = message.getElementsByTagName('stamp')[0];
const delay = message.getElementsByTagName('delay')[0];

const messageBody = message.getElementsByTagName('body')[0]
.textContent;
const from = StringUtils.removeAfterInclChar(
message.getElementsByTagName('message')[0].getAttribute('from'),
'@'
);
const unformattedDate = new Date(stamp);

let unformattedDate;

if (stamp !== undefined) unformattedDate = new Date(stamp.textContent);
else if (delay !== undefined) unformattedDate = new Date(delay.getAttribute('stamp'));

let ownMessage = false;
if (from === authUser.username) {
ownMessage = true;
Expand Down
26 changes: 14 additions & 12 deletions utils/cache-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default {
store.state.app.authUser.username,
store.state.chat.conversationList
);
}, 500);
}, 3000);
return;
}

Expand Down Expand Up @@ -111,18 +111,20 @@ export default {
});
};

recGetOldMessages(0);
const recOldMessages = recGetOldMessages(0);
} else {
store.dispatch('chat/updateDelayIncomingMessages', false);
store.dispatch('app/updateIsAppLoading', false);
const delayedMessageList = store.state.chat.delayedMessageList;
delayedMessageList.forEach(function(msg) {
XmppUtils.messageHandler(msg);
});
this.saveConversationList(
store.state.app.authUser.username,
store.state.chat.conversationList
);
setTimeout(() => {
store.dispatch('chat/updateDelayIncomingMessages', false);
store.dispatch('app/updateIsAppLoading', false);
const delayedMessageList = store.state.chat.delayedMessageList;
delayedMessageList.forEach(function(msg) {
XmppUtils.messageHandler(msg);
});
this.saveConversationList(
store.state.app.authUser.username,
store.state.chat.conversationList
);
}, 3000);
}
}
};
3 changes: 3 additions & 0 deletions utils/xmpp-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ export default {
const type = msg.getAttribute('type');
const body = msg.getElementsByTagName('body')[0];
const stamp = msg.getElementsByTagName('stamp')[0];
const delay = msg.getElementsByTagName('delay')[0];
const composing = msg.getElementsByTagName('composing')[0];
const paused = msg.getElementsByTagName('paused')[0];

Expand All @@ -212,6 +213,7 @@ export default {
let newDate = new Date();

if (stamp !== undefined) newDate = new Date(stamp.textContent);
else if (delay !== undefined) newDate = new Date(delay.getAttribute('stamp'));

MessageBox.alert(
`${newDate.toLocaleString(locale)}:<br> ` +
Expand All @@ -228,6 +230,7 @@ export default {
const msgContent = body.textContent;
let newDate = new Date();
if (stamp !== undefined) newDate = new Date(stamp.textContent);
else if (delay !== undefined) newDate = new Date(delay.getAttribute('stamp'));

if (conversation !== undefined) {
if (
Expand Down

0 comments on commit 6e625a8

Please sign in to comment.