portal may become unselected
This simplifies the logic a bit, hopefully making it easier to debug the issue See #404. It seems to be related to when the portal changed because I could trigger it easily on zooming in/out when there was a cache bug that gave me an R portal in one zoom level and an E one in the other.
This commit is contained in:
@ -144,25 +144,26 @@ window.handleDataResponse = function(data, textStatus, jqXHR) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.handlePortalsRender = function(portals) {
|
window.handlePortalsRender = function(portals) {
|
||||||
var portalUpdateAvailable = false;
|
|
||||||
var portalInUrlAvailable = false;
|
var portalInUrlAvailable = false;
|
||||||
|
|
||||||
// Preserve and restore "selectedPortal" between portal re-render
|
// Preserve selectedPortal because it will get lost on re-rendering
|
||||||
if(portalUpdateAvailable) var oldSelectedPortal = selectedPortal;
|
// the portal
|
||||||
|
var oldSelectedPortal = selectedPortal;
|
||||||
|
|
||||||
runHooks('portalDataLoaded', {portals : portals});
|
runHooks('portalDataLoaded', {portals : portals});
|
||||||
$.each(portals, function(ind, portal) {
|
$.each(portals, function(ind, portal) {
|
||||||
if(selectedPortal === portal[0]) portalUpdateAvailable = true;
|
//~ if(selectedPortal === portal[0]) portalUpdateAvailable = true;
|
||||||
if(urlPortal && portal[0] == urlPortal) portalInUrlAvailable = true;
|
if(urlPortal && portal[0] === urlPortal) portalInUrlAvailable = true;
|
||||||
renderPortal(portal);
|
renderPortal(portal);
|
||||||
});
|
});
|
||||||
|
|
||||||
var selectedPortalLayer = portals[oldSelectedPortal];
|
// restore selected portal if still available
|
||||||
if(portalUpdateAvailable && selectedPortalLayer) selectedPortal = oldSelectedPortal;
|
var selectedPortalGroup = portals[oldSelectedPortal];
|
||||||
|
if(selectedPortalGroup) {
|
||||||
if(selectedPortalLayer) {
|
selectedPortal = oldSelectedPortal;
|
||||||
|
renderPortalDetails(selectedPortal);
|
||||||
try {
|
try {
|
||||||
selectedPortalLayer.bringToFront();
|
selectedPortalGroup.bringToFront();
|
||||||
} catch(e) { /* portal is now visible, catch Leaflet error */ }
|
} catch(e) { /* portal is now visible, catch Leaflet error */ }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,8 +171,6 @@ window.handlePortalsRender = function(portals) {
|
|||||||
renderPortalDetails(urlPortal);
|
renderPortalDetails(urlPortal);
|
||||||
urlPortal = null; // select it only once
|
urlPortal = null; // select it only once
|
||||||
}
|
}
|
||||||
|
|
||||||
if(portalUpdateAvailable) renderPortalDetails(selectedPortal);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// removes entities that are still handled by Leaflet, although they
|
// removes entities that are still handled by Leaflet, although they
|
||||||
|
Reference in New Issue
Block a user