-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
If a value is deleted from the nav link collection, invalidate in-order cache #7227
If a value is deleted from the nav link collection, invalidate in-order cache #7227
Conversation
Otherwise, the next time inOrder is called, the stale nav link collection that is in the cache is returned, with the deleted object still in it.
@@ -26,4 +26,9 @@ export default class UiNavLinkCollection extends Collection { | |||
return this[inOrderCache]; | |||
} | |||
|
|||
delete(value) { | |||
super.delete(value); | |||
this[inOrderCache] = null; |
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.
How about moving this before super.delete()
and returning the calls return value?
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.
Yeah, makes sense as delete returns a boolean. Thanks!
LGTM |
I'm singling this PR out purely for convenience sake: Especially for PRs that don't have an associated issue, it'd be really helpful to provide a description about what problem is being solved. |
Makes sense. I'll update the description now. |
@epixa Description updated. |
Thanks! |
The
UiNavLinkCollection
class maintains a list of nav links shown in the Kibana UI. Instances of this class have a property calledinOrderCache
that is meant to contain the list of nav links, in order of theirorder
properties. ThisinOrderCache
property is populated when theinOrder()
instance method is called the first time; subsequent calls to theinOrder()
method simply return the list ininOrderCache
.As the
UiNavLinkCollection
inherits from theCollection
class, it also has adelete()
instance method that can be called to delete a nav link from the list of nav links. Thisdelete()
method needs to be overriden to invalidate theinOrderCache
each time a link is deleted. Otherwise, the next timeinOrder()
is called, the stale cached nav link collection is returned, with the deleted object still in it. This PR implements this fix.