mirror of
https://github.com/twisterarmy/twister-html.git
synced 2025-01-27 23:24:26 +00:00
rewrite processDmConversation() to avoid appending of double posts in DMs
This commit is contained in:
parent
73ae8a96cd
commit
b622635952
@ -78,24 +78,29 @@ function requestDmConversation(postboard, dm_screenname) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function processDmConversation(postboard, dm_screenname, dmData) {
|
function processDmConversation(stream, peerAlias, posts) {
|
||||||
var lastId = undefined;
|
var streamItems = stream.children();
|
||||||
|
var streamPostsIDs = [];
|
||||||
|
|
||||||
if (dmData[dm_screenname]) {
|
for (var i = 0; i < streamItems.length; i++) {
|
||||||
var dmList = dmData[dm_screenname];
|
streamPostsIDs.push(parseInt(streamItems.eq(i).attr('data-id')));
|
||||||
if (dmList.length) {
|
|
||||||
for (var i = 0; i < dmList.length; i++) {
|
|
||||||
var dmItem = postToElemDM(dmList[i], defaultScreenName, dm_screenname)
|
|
||||||
.attr('data-id', dmList[i].id)
|
|
||||||
.appendTo(postboard)
|
|
||||||
;
|
|
||||||
lastId = dmList[i].id;
|
|
||||||
}
|
|
||||||
$.MAL.dmChatListLoaded(postboard);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (typeof lastId !== 'undefined')
|
|
||||||
resetNewDMsCountForUser(dm_screenname, lastId);
|
if (posts[peerAlias] && posts[peerAlias].length) {
|
||||||
|
for (var i = 0; i < posts[peerAlias].length; i++) {
|
||||||
|
if (streamPostsIDs.indexOf(posts[peerAlias][i].id) === -1) {
|
||||||
|
var lastPostID = posts[peerAlias][i].id;
|
||||||
|
postToElemDM(posts[peerAlias][i], defaultScreenName, peerAlias)
|
||||||
|
.attr('data-id', lastPostID)
|
||||||
|
.appendTo(stream)
|
||||||
|
;
|
||||||
|
streamPostsIDs.push(lastPostID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$.MAL.dmChatListLoaded(stream);
|
||||||
|
}
|
||||||
|
if (typeof lastPostID !== 'undefined')
|
||||||
|
resetNewDMsCountForUser(peerAlias, lastPostID);
|
||||||
}
|
}
|
||||||
|
|
||||||
function directMsgSubmit(e) {
|
function directMsgSubmit(e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user