-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Permanent portal entities #437
base: master
Are you sure you want to change the base?
Conversation
228aa0e
to
7e9c1e7
Compare
See also #251 |
d2aec21
to
dd0c20b
Compare
core/code/portal_marker.js
Outdated
} | ||
function handler_portal_dblclick (e) { | ||
e.target.select(true); | ||
handler_portal_click(e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BAD!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is so bad for you to capslock ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
click/dblclicl/contexmenu - are separate actions.
Don't call one from another, even if currently it does the job.
Better make separate function for these calls:
window.selectPortal(e.target.options.guid, e.type);
window.renderPortalDetails(e.target.options.guid, true)
Also I suspect that we we can refactor code to leave only one of these.
Please consider this use case: #195 |
It is, using standard |
But what will happen when placeholder will be replaced with real entity? What if it will be moved from one faction to another, etc. |
placeholders are not destroyed but updated when we get real data.
the main feature (permanent portal entities) is ready for testing the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link/field timestamp may be higher than the portal timestamp, breaking the logic
Maybe use a timestamp minus decay time...
c4560ee
to
21faf55
Compare
core/code/portal_detail_display.js
Outdated
@@ -9,8 +9,8 @@ window.resetScrollOnNewPortal = function() { | |||
} | |||
}; | |||
|
|||
window.renderPortalDetails = function(guid) { | |||
selectPortal(window.portals[guid] ? guid : null); | |||
window.renderPortalDetails = function(guid, dontSelect) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
window.renderPortalDetails = function(guid, dontSelect) { | |
window.renderPortalDetails = function(guid) { |
I haven't reviewed this PR as a whole, but still believe that here we need slightly different logic:
do not select portal if it is already set as current without additional arguments: #442 (comment)
In case if we will found that it is still required in some special case, then we better add opposite:
window.renderPortalDetails = function(guid, dontSelect) { | |
window.renderPortalDetails = function(guid, forceSelect) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Second looks saner.
My though was to not break (unknonwn) plugins that would assume renderPortalDetails triggers a portalSelected
event as long as the portal has its own marker.
But I bet plugins relying on this will eventually update to match the needs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I bet plugins relying on this will eventually update to match the needs
So am I.
Let's try to remove dontSelect
, may be taht will be best for all.
|
||
marker.updateDetails(data); | ||
|
||
window.runHooks('portalAdded', {portal: marker, previousData: previousData}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the hook is misleading now since the marker is the same marker. Only the data changed.
In this case, we are closer to the portalDetailLoaded
but with eventually no details (i.e. from core to summary/extended)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the hook is misleading
But that was expected, that's why previousData
provided. I suppose we should leave it as it.
May be we should add some property to denote placeholders.
But we can revise that from scratch when implementing #217.
5257ed8
to
bb5e120
Compare
Could you point exact places in code? (I haven't studied this PR yet). |
I introduced link/field timestamp as placeholder timestamp instead of the value In many cases, the link/field timestamp is more recent that the portal timestamp. The previous rule that portal data is ignored if timestamp is older prevents the marker to update from detailed data (while getPortalDetails are always up to date to my knowledge). I fix this following this new rule about placeholder (provided the field/link timestamp):
Uses cases:
|
bb5e120
to
4129d76
Compare
And what if that portal had links/fields attached? P.S. |
I don't understand your question The current code is also trusting the team of placeholders, whatever the timestamp of the attached field/links.
A plugin could do this to update the map before getEntities... |
Imaging that we have Green portal with links and fields. |
Since data is fresher, the portal is updated to blue, the links may stays until the the next getEntities request you should give a look to |
apply/adapt set(Marker)Style PR IITC-CE#251 by johnd0e commit 6201837
avoid missing details when getEntities replies that the portal has changed while portal details is still fresh (3min) in cache
This reverts commit 1878ec6.
photo/title
Address #325
Changes
Extend the CircleMarker class to PortalMarker class following the same idea of #251
Portal entities are only deleted when removed from rendering:
On any other situtation, the portal marker is the same and only receive updates until removed from rendering.
class
L.PortalMarker
Methods:
setStyle(style)
(deprecated, for compatibility with old highlighters)don't apply a style, but save it for later when calling
setMarkerStyle
setMarkerStyle(style)
setSelected(details)
willUpdate(details)
updateDetails(details)
getDetails()
hasFullDetails()
renderDetails()
renderPortalDetails
(even if unselected) while avoiding a call toselectPortal
Hooks
portalSelected
Add a new field
event
that specified the origin of the event.This is mainly to distinguish a selection that comes from a call to
renderPortalDetails
and a click/touch event on the marker from the user.Portal Details Cache
Before
on
portalDetail.request
, the data is parsed, store, used for render portal details in the side bar if the portal is selected, then theportalDetailLoaded
hook trigger the creation of a new portal entity.portal entity only stores partial data (summary only but full raw)
Now
on
portalDetail.request
, we create or update a portal entity, this part renders the portal details if needed, store the portal details in cache, run theportalDetailLoaded
hook.portal detail cache is used for incomplete portal entity upon creation
Gain: the portal entity always has the most recent data, details are parsed once, the portal entity is sure to exist for the hook.
Missing: if the portal changed before details in cache expires, the code won't fetch new details unless a direct call tosee a587775portalDetail.request
(is it true before also?)Placeholder entities
Placeholder portal entities are introduced for link/field endpoints.
Fields and links have an unused timestamp.
The PR uses the timestamp from link/field to handle portal updates as any other portal entity.
Sidenotes
Portal timestamp change on portal edit (title, location, portal main picture).
deprecated:
window.createMarker
window.setMarkerStyle
From #251
related functions (next candidates for refactoring/deprecation)
window.setPortalIndicators
window.selectPortal
window.portalMarkerScale
window.getMarkerStyleOptions
window.renderPortalDetails