Improve performance of asynchronous like/update
- Make the like module return earlier instead of outputting a full empty HTML page - Update the force_update variable earlier to prevent spilling on multiple unrelated nav update calls
This commit is contained in:
parent
9ebb2c6527
commit
2d217129b9
2 changed files with 10 additions and 6 deletions
|
@ -22,6 +22,7 @@
|
|||
namespace Friendica\Module;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Core\Session;
|
||||
|
@ -68,5 +69,7 @@ class Like extends BaseModule
|
|||
|
||||
DI::baseUrl()->redirect($returnPath . $rand);
|
||||
}
|
||||
|
||||
System::jsonExit(['status' => 'OK']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -594,15 +594,17 @@ function liveUpdate(src) {
|
|||
|
||||
in_progress = true;
|
||||
|
||||
if ($(document).scrollTop() == 0) {
|
||||
force_update = true;
|
||||
}
|
||||
let force = force_update || $(document).scrollTop() === 0;
|
||||
|
||||
var orgHeight = $("section").height();
|
||||
|
||||
var udargs = ((netargs.length) ? '/' + netargs : '');
|
||||
|
||||
var update_url = 'update_' + src + udargs + '&p=' + profile_uid + '&force=' + ((force_update) ? 1 : 0) + '&item=' + update_item;
|
||||
var update_url = 'update_' + src + udargs + '&p=' + profile_uid + '&force=' + (force ? 1 : 0) + '&item=' + update_item;
|
||||
|
||||
if (force_update) {
|
||||
force_update = false;
|
||||
}
|
||||
|
||||
if (getUrlParameter('page')) {
|
||||
update_url += '&page=' + getUrlParameter('page');
|
||||
|
@ -614,9 +616,8 @@ function liveUpdate(src) {
|
|||
update_url += '&max_id=' + getUrlParameter('max_id');
|
||||
}
|
||||
|
||||
$.get(update_url,function(data) {
|
||||
$.get(update_url, function(data) {
|
||||
in_progress = false;
|
||||
force_update = false;
|
||||
update_item = 0;
|
||||
|
||||
$('.wall-item-body', data).imagesLoaded(function() {
|
||||
|
|
Loading…
Reference in a new issue