Optimize delta callbacks (new feed)

This commit is contained in:
2021-09-05 20:07:09 +02:00
parent cf49a17266
commit 581581d86c
6 changed files with 25 additions and 22 deletions

View File

@@ -551,13 +551,14 @@ class Spot extends Main
} }
//Sort Table IDs by type & Get attributes //Sort Table IDs by type & Get attributes
$asFeedIds = array('message'=>array(), 'media'=>array(), 'message'=>array());
foreach($asItems as $asItem) { foreach($asItems as $asItem) {
$asFeedIds[$asItem['type']][$asItem['id']] = $asItem; $asFeedIds[$asItem['type']][$asItem['id']] = $asItem;
} }
$asFeedAttrs = array( $asFeedAttrs = array(
'message' => $this->getSpotMessages(array_keys($asFeedIds['message'])), 'message' => empty($asFeedIds['message'])?array():$this->getSpotMessages(array_keys($asFeedIds['message'])),
'media' => $this->getMedias($sMediaRefField, array_keys($asFeedIds['media'])), 'media' => empty($asFeedIds['media'])?array():$this->getMedias($sMediaRefField, array_keys($asFeedIds['media'])),
'post' => $this->getPosts(array_keys($asFeedIds['post'])) 'post' => empty($asFeedIds['post'])?array():$this->getPosts(array_keys($asFeedIds['post']))
); );
//Replace Array Key with Item ID //Replace Array Key with Item ID

View File

@@ -776,23 +776,26 @@ function updateFeed(bFirstChunk, bDiscrete, fCallback) {
function focusOnPost(oFocusPost) { function focusOnPost(oFocusPost) {
if(oFocusPost) { if(oFocusPost) {
var sElemId = '#'+oFocusPost.type+'-'+oFocusPost.id; if(oFocusPost.type=='message' && (!oSpot.tmp(['markers', oFocusPost.id]) || !oSpot.tmp('map'))) setTimeout(function(){focusOnPost(oFocusPost);}, 100);
var $Post = oSpot.tmp('$PostList').find(sElemId); else {
var bGetToTop = (oSpot.tmp('$PostList').height() - (($Post.length > 0)?$Post.position().top:0) >= $(window).height()); var sElemId = '#'+oFocusPost.type+'-'+oFocusPost.id;
if($Post.length > 0 && (bGetToTop || self.tmp('out-of-data'))) { var $Post = oSpot.tmp('$PostList').find(sElemId);
self.tmp('simple-bar').getScrollElement().scrollTop = Math.round( var bGetToTop = (oSpot.tmp('$PostList').height() - (($Post.length > 0)?$Post.position().top:0) >= $(window).height());
$Post.position().top + if($Post.length > 0 && (bGetToTop || self.tmp('out-of-data'))) {
parseInt($Post.css('margin-top')) + self.tmp('simple-bar').getScrollElement().scrollTop = Math.round(
(self.tmp('$Poster').is(':visible')?self.tmp('$Poster').outerHeight(true):0) $Post.position().top +
); parseInt($Post.css('margin-top')) +
(self.tmp('$Poster').is(':visible')?self.tmp('$Poster').outerHeight(true):0)
);
if(oFocusPost.type=='media' || oFocusPost.type=='message') $Post.find('a.drill').click(); if(oFocusPost.type=='media' || oFocusPost.type=='message') $Post.find('a.drill').click();
}
else if(!self.tmp('out-of-data')) updateFeed(false, false, function() {focusOnPost(oFocusPost);});
else console.log('Missing element ID '+sElemId);
//Reset Hash
oSpot.flushHash(['post', 'message']);
} }
else if(!self.tmp('out-of-data')) updateFeed(false, false, function() {focusOnPost(oFocusPost);});
else console.log('Missing element ID '+sElemId);
//Reset Hash
oSpot.flushHash(['post', 'message']);
} }
} }

View File

@@ -25,4 +25,4 @@
* Add mail frequency slider * Add mail frequency slider
* Use WMTS servers directly when not using Geo Caching Server * Use WMTS servers directly when not using Geo Caching Server
* Allow HEIF picture format * Allow HEIF picture format
* pbf map format (https://www.arcgis.com/home/item.html?id=7dc6cea0b1764a1f9af2e679f642f0f5) * Vector tiles support (https://www.arcgis.com/home/item.html?id=7dc6cea0b1764a1f9af2e679f642f0f5). Use Mapbox GL JS / Maplibre GL JS?

View File

@@ -531,7 +531,6 @@ $legend-color: $post-color;
border-radius: $block-radius; border-radius: $block-radius;
background: $message-bg; background: $message-bg;
color: $message-color; color: $message-color;
font-size: 1.2em;
cursor: pointer; cursor: pointer;
padding: $elem-spacing; padding: $elem-spacing;
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long