Fix load metadata (#16417)

GitOrigin-RevId: 26505e08ca9074238253dba08d0380422ae859be
This commit is contained in:
Alf Eaton 2024-01-08 12:07:28 +00:00 committed by Copybot
parent e27abe56b8
commit e91b76a4f0

View file

@ -184,6 +184,12 @@ export const MetadataProvider: FC = ({ children }) => {
useEventListener('editor:metadata-outdated', handleMetadataOutdated)
const permissionsRef = useRef(permissions)
useEffect(() => {
permissionsRef.current = permissions
}, [permissions])
useEffect(() => {
const handleProjectJoined = ({
detail: [{ project }],
@ -195,7 +201,7 @@ export const MetadataProvider: FC = ({ children }) => {
)
}
window.setTimeout(() => {
if (permissions.write) {
if (permissionsRef.current.write) {
loadProjectMetaFromServer()
}
}, 200)
@ -206,13 +212,7 @@ export const MetadataProvider: FC = ({ children }) => {
return () => {
eventEmitter.off('project:joined', handleProjectJoined)
}
}, [
eventEmitter,
loadProjectMetaFromServer,
permissions,
showGenericMessageModal,
t,
])
}, [eventEmitter, loadProjectMetaFromServer, showGenericMessageModal, t])
const value = useMemo<MetadataContextValue>(
() => ({