Browse Source

sort DM thread list by date

sort DM thread list by date
master
Hedgehog 11 years ago
parent
commit
18d6ad4f62
  1. 18
      js/twister_directmsg.js
  2. 3
      js/twister_formatpost.js

18
js/twister_directmsg.js

@ -19,8 +19,24 @@ function processDMsnippet(dmUsers, dmThreadList) { @@ -19,8 +19,24 @@ function processDMsnippet(dmUsers, dmThreadList) {
for( var u in dmUsers ) {
if( dmUsers.hasOwnProperty(u) ) {
// convert snipped to html and add it to date-sorted list
var dmItem = dmDataToSnippetItem(dmUsers[u][0], u);
dmThreadList.append(dmItem);
var timeDmItem = parseInt(dmItem.attr("data-time"));
var existingItems = dmThreadList.children();
var j = 0;
for( j = 0; j < existingItems.length; j++) {
var streamItem = existingItems.eq(j);
var timeExisting = streamItem.attr("data-time");
if( timeExisting == undefined ||
timeDmItem > parseInt(timeExisting) ) {
// this post in stream is older, so post must be inserted above
streamItem.before(dmItem);
break;
}
}
if( j == existingItems.length ) {
dmThreadList.append(dmItem);
}
}
}
$.MAL.dmThreadListLoaded();

3
js/twister_formatpost.js

@ -118,7 +118,8 @@ function dmDataToSnippetItem(dmData, remoteUser) { @@ -118,7 +118,8 @@ function dmDataToSnippetItem(dmData, remoteUser) {
dmItem.removeAttr('id');
dmItem.attr("data-dm-screen-name",remoteUser);
dmItem.attr("data-last_id", dmData.id);
dmItem.attr("data-time", dmData.time);
dmItem.find(".post-info-tag").text("@" + remoteUser);
dmItem.find("a.post-info-name").attr("href", $.MAL.userUrl(remoteUser));
dmItem.find("a.dm-chat-link").attr("href", $.MAL.dmchatUrl(remoteUser));

Loading…
Cancel
Save