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