Browse Source

add mentions' retrievement on scroll to the bottom of the mentions modal

readme-update
Simon Grim 8 years ago
parent
commit
9e17f2da10
  1. 4
      js/interface_common.js
  2. 27
      js/twister_newmsgs.js

4
js/interface_common.js

@ -679,9 +679,11 @@ function openMentionsModalHandler(peerAlias) {
) )
; ;
if (peerAlias === defaultScreenName) if (peerAlias === defaultScreenName) {
modal.content.on('scroll', handleMentionsModalScroll);
resetMentionsCount(); resetMentionsCount();
} }
}
function openFollowersModal(peerAlias) { function openFollowersModal(peerAlias) {
var followers, title, warn; var followers, title, warn;

27
js/twister_newmsgs.js

@ -44,6 +44,8 @@ function loadMentionsFromStorage() {
twister.mentions.twists.cached[j] = mentions.twists[i]; twister.mentions.twists.cached[j] = mentions.twists[i];
if (twister.mentions.twists.cached[j].isNew) if (twister.mentions.twists.cached[j].isNew)
twister.mentions.lengthNew++; twister.mentions.lengthNew++;
twister.mentions.lengthFromTorrent++;
} }
} }
twister.mentions.lastTime = mentions.lastTime; twister.mentions.lastTime = mentions.lastTime;
@ -61,6 +63,8 @@ function loadMentionsFromStorage() {
twister.mentions.twists.cached[j] = mentions[i].data; twister.mentions.twists.cached[j] = mentions[i].data;
if (twister.mentions.twists.cached[j].isNew) if (twister.mentions.twists.cached[j].isNew)
twister.mentions.lengthNew++; twister.mentions.lengthNew++;
twister.mentions.lengthFromTorrent++;
} }
} }
@ -94,6 +98,7 @@ function queryPendingPushMentions(req, res) {
if (res[i].id) { if (res[i].id) {
twister.res[req].lastTorrentId = Math.max(twister.res[req].lastTorrentId, res[i].id); twister.res[req].lastTorrentId = Math.max(twister.res[req].lastTorrentId, res[i].id);
delete res[i].id; delete res[i].id;
twister.res[req].lengthFromTorrent++;
} }
var j = res[i].userpost.n + '/' + res[i].userpost.time; var j = res[i].userpost.n + '/' + res[i].userpost.time;
@ -137,6 +142,7 @@ function initMentionsCount() {
lengthNew: 0, lengthNew: 0,
ready: function (req) { ready: function (req) {
twister.mentions = twister.res[req]; twister.mentions = twister.res[req];
twister.mentions.lengthFromTorrent = 0;
loadMentionsFromStorage(); loadMentionsFromStorage();
}, },
skidoo: function () {return false;} skidoo: function () {return false;}
@ -145,6 +151,27 @@ function initMentionsCount() {
$.MAL.updateNewMentionsUI(twister.mentions.lengthNew); $.MAL.updateNewMentionsUI(twister.mentions.lengthNew);
} }
function handleMentionsModalScroll(event) {
if (!event || twister.mentions.scrollQueryActive)
return;
var elem = $(event.target);
if (elem.scrollTop() >= elem[0].scrollHeight - elem.height() - 50) {
twister.mentions.scrollQueryActive = true;
twisterRpc('getmentions', [twister.mentions.query, 10,
{max_id: twister.mentions.lastTorrentId - twister.mentions.lengthFromTorrent}],
function (req, res) {
twister.mentions.scrollQueryActive = false;
twister.res[req].boardAutoAppend = true; // FIXME all pending twists will be appended
queryProcess(req, res);
twister.res[req].boardAutoAppend = false;
}, twister.mentions.query + '@' + twister.mentions.resource,
function () {console.warn('getmentions API requires twister-core > 0.9.27');}
);
}
}
// --- direct messages --- // --- direct messages ---
var _lastDMIdPerUser = {}; var _lastDMIdPerUser = {};

Loading…
Cancel
Save