Browse Source

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

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

4
js/interface_common.js

@ -679,8 +679,10 @@ function openMentionsModalHandler(peerAlias) { @@ -679,8 +679,10 @@ function openMentionsModalHandler(peerAlias) {
)
;
if (peerAlias === defaultScreenName)
if (peerAlias === defaultScreenName) {
modal.content.on('scroll', handleMentionsModalScroll);
resetMentionsCount();
}
}
function openFollowersModal(peerAlias) {

27
js/twister_newmsgs.js

@ -44,6 +44,8 @@ function loadMentionsFromStorage() { @@ -44,6 +44,8 @@ function loadMentionsFromStorage() {
twister.mentions.twists.cached[j] = mentions.twists[i];
if (twister.mentions.twists.cached[j].isNew)
twister.mentions.lengthNew++;
twister.mentions.lengthFromTorrent++;
}
}
twister.mentions.lastTime = mentions.lastTime;
@ -61,6 +63,8 @@ function loadMentionsFromStorage() { @@ -61,6 +63,8 @@ function loadMentionsFromStorage() {
twister.mentions.twists.cached[j] = mentions[i].data;
if (twister.mentions.twists.cached[j].isNew)
twister.mentions.lengthNew++;
twister.mentions.lengthFromTorrent++;
}
}
@ -94,6 +98,7 @@ function queryPendingPushMentions(req, res) { @@ -94,6 +98,7 @@ function queryPendingPushMentions(req, res) {
if (res[i].id) {
twister.res[req].lastTorrentId = Math.max(twister.res[req].lastTorrentId, res[i].id);
delete res[i].id;
twister.res[req].lengthFromTorrent++;
}
var j = res[i].userpost.n + '/' + res[i].userpost.time;
@ -137,6 +142,7 @@ function initMentionsCount() { @@ -137,6 +142,7 @@ function initMentionsCount() {
lengthNew: 0,
ready: function (req) {
twister.mentions = twister.res[req];
twister.mentions.lengthFromTorrent = 0;
loadMentionsFromStorage();
},
skidoo: function () {return false;}
@ -145,6 +151,27 @@ function initMentionsCount() { @@ -145,6 +151,27 @@ function initMentionsCount() {
$.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 ---
var _lastDMIdPerUser = {};

Loading…
Cancel
Save