Open johnd0e opened 4 years ago
I propose to change this approach to some more simple and consistent: keep same portal marker, and only update it's data.
But we must consider compatibility, so all current hooks should stay.
update
(both hooks)Related problem?
Hook portalSelected
gets executed two or three times when a portal is selected.
code to check:
window.addHook("portalSelected", someFunction);
function someFunction(d) {
console.log(d);
}
Currently portal entity (represented by CircleMarker) is not permanent: every time we get some data with newer timestamp - portal marker is recreated:
https://github.com/IITC-CE/ingress-intel-total-conversion/blob/36a9b69e55c409a091523401422f532e628c3b1d/core/code/map_data_render.js#L292-L307createPortalEntity()
So all additional data (potentially attached by plugins) is discarded, including event listeners and other leaflet-binded things. In such case two hooks are run consequentially:
So data is discarded, but not completely lost: plugin may restore some data from
previousData
property. But as you see it's not so obvious and in many cases it may be tricky or cumbersome - to keep continuity between separated portal entities.I propose to change this approach to some more simple and consistent: keep same portal marker, and only update it's data. Examples of potential benefits: