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
Plugins: Refresh plugin info after installation #75074
Conversation
|
||
return (id: string) => dispatch(fetchDetails(id)); | ||
} | ||
|
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.
Although this should work, maybe what we could do instead is to add a way to force-fetch with the existing useFetchDetails()
hook - in that case we would only have a single way for fetching plugin details using hooks.
E.g.:
export const useFetchDetails = (id: string, { force = false } = {}) => {
const dispatch = useDispatch();
const plugin = useSelector((state) => selectById(state, id));
const isNotFetching = !useSelector(selectIsRequestPending(fetchDetails.typePrefix));
const shouldFetch = force || (isNotFetching && plugin && !plugin.details);
useEffect(() => {
shouldFetch && dispatch(fetchDetails(id));
}, [plugin]); // eslint-disable-line
};
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.
@leventebalogh tks for your review.
I tried a similar approach before, removing the !plugin.details
from shouldFetch
caused a infinite loop. The main problem is that fetchDetails
is inside useEffect
in this existing hook. That's why I went for the lazy fetch.
The suggested approach will cause the same.
Just to check if I'm not doing anything wrong: I changed the useFetchDetails
, as you suggested, and then added the hook in InstallControlsButton
component right before the first useEffect
that is already there.
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, you are actually right - I missed that useFetchDetails()
is not returning with a function.
Let's leave it as it is 👍
|
||
return (id: string) => dispatch(fetchDetails(id)); | ||
} | ||
|
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, you are actually right - I missed that useFetchDetails()
is not returning with a function.
Let's leave it as it is 👍
(cherry picked from commit 6600dd2)
What is this feature?
After a plugin installation the redux store was still holding old data, we need to refresh it after installation
Why do we need this feature?
This is necessary to have the right info in shown in plugin catalog right after installation
Who is this feature for?
Plugins users
Which issue(s) does this PR fix?:
Fixes part of #68395
Special notes for your reviewer:
Please check that: