Optimize delta callbacks (new feed)

This commit is contained in:
2021-09-05 20:07:09 +02:00
parent 51e0565e67
commit e9f7cae5f9
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
$asFeedIds = array('message'=>array(), 'media'=>array(), 'message'=>array());
foreach($asItems as $asItem) {
$asFeedIds[$asItem['type']][$asItem['id']] = $asItem;
}
$asFeedAttrs = array(
'message' => $this->getSpotMessages(array_keys($asFeedIds['message'])),
'media' => $this->getMedias($sMediaRefField, array_keys($asFeedIds['media'])),
'post' => $this->getPosts(array_keys($asFeedIds['post']))
'message' => empty($asFeedIds['message'])?array():$this->getSpotMessages(array_keys($asFeedIds['message'])),
'media' => empty($asFeedIds['media'])?array():$this->getMedias($sMediaRefField, array_keys($asFeedIds['media'])),
'post' => empty($asFeedIds['post'])?array():$this->getPosts(array_keys($asFeedIds['post']))
);
//Replace Array Key with Item ID

View File

@@ -776,23 +776,26 @@ function updateFeed(bFirstChunk, bDiscrete, fCallback) {
function focusOnPost(oFocusPost) {
if(oFocusPost) {
var sElemId = '#'+oFocusPost.type+'-'+oFocusPost.id;
var $Post = oSpot.tmp('$PostList').find(sElemId);
var bGetToTop = (oSpot.tmp('$PostList').height() - (($Post.length > 0)?$Post.position().top:0) >= $(window).height());
if($Post.length > 0 && (bGetToTop || self.tmp('out-of-data'))) {
self.tmp('simple-bar').getScrollElement().scrollTop = Math.round(
$Post.position().top +
parseInt($Post.css('margin-top')) +
(self.tmp('$Poster').is(':visible')?self.tmp('$Poster').outerHeight(true):0)
);
if(oFocusPost.type=='message' && (!oSpot.tmp(['markers', oFocusPost.id]) || !oSpot.tmp('map'))) setTimeout(function(){focusOnPost(oFocusPost);}, 100);
else {
var sElemId = '#'+oFocusPost.type+'-'+oFocusPost.id;
var $Post = oSpot.tmp('$PostList').find(sElemId);
var bGetToTop = (oSpot.tmp('$PostList').height() - (($Post.length > 0)?$Post.position().top:0) >= $(window).height());
if($Post.length > 0 && (bGetToTop || self.tmp('out-of-data'))) {
self.tmp('simple-bar').getScrollElement().scrollTop = Math.round(
$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
* Use WMTS servers directly when not using Geo Caching Server
* 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;
background: $message-bg;
color: $message-color;
font-size: 1.2em;
cursor: pointer;
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