mirror of
https://github.com/twisterarmy/twister-html.git
synced 2025-01-14 08:58:05 +00:00
add mentions' retrievement on scroll to the bottom of the mentions modal
This commit is contained in:
parent
059616e0ac
commit
9e17f2da10
@ -679,8 +679,10 @@ function openMentionsModalHandler(peerAlias) {
|
||||
)
|
||||
;
|
||||
|
||||
if (peerAlias === defaultScreenName)
|
||||
if (peerAlias === defaultScreenName) {
|
||||
modal.content.on('scroll', handleMentionsModalScroll);
|
||||
resetMentionsCount();
|
||||
}
|
||||
}
|
||||
|
||||
function openFollowersModal(peerAlias) {
|
||||
|
@ -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() {
|
||||
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) {
|
||||
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() {
|
||||
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() {
|
||||
$.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…
Reference in New Issue
Block a user