@@ -32,9 +32,9 @@ function PostLockedModal() {
3232		postId, 
3333		postLockUtils, 
3434		activePostLock, 
35+ 		postSupportsSync, 
3536		postType, 
3637		previewLink, 
37- 		supportsSync, 
3838	}  =  useSelect (  (  select  )  =>  { 
3939		const  { 
4040			isPostLocked, 
@@ -48,22 +48,27 @@ function PostLockedModal() {
4848			getEditorSettings, 
4949		}  =  select (  editorStore  ) ; 
5050		const  {  getPostType,  getEntityConfig }  =  select (  coreStore  ) ; 
51- 		const  currentPostType  =  getCurrentPostType ( ) ; 
5251		return  { 
5352			isLocked : isPostLocked ( ) , 
5453			isTakeover : isPostLockTakeover ( ) , 
5554			user : getPostLockUser ( ) , 
5655			postId : getCurrentPostId ( ) , 
5756			postLockUtils : getEditorSettings ( ) . postLockUtils , 
5857			activePostLock : getActivePostLock ( ) , 
58+ 			postSupportsSync : Boolean ( 
59+ 				getEntityConfig (  'postType' ,  getCurrentPostType ( )  ) ?. syncConfig 
60+ 			) , 
5961			postType : getPostType (  getEditedPostAttribute (  'type'  )  ) , 
6062			previewLink : getEditedPostPreviewLink ( ) , 
61- 			supportsSync : Boolean ( 
62- 				getEntityConfig (  'postType' ,  currentPostType  ) ?. syncConfig 
63- 			) , 
6463		} ; 
6564	} ,  [ ]  ) ; 
6665
66+ 	let  syncEnabled  =  false ; 
67+ 	if  (  globalThis . IS_GUTENBERG_PLUGIN  )  { 
68+ 		syncEnabled  = 
69+ 			postSupportsSync  &&  Boolean (  window . __experimentalEnableSync  ) ; 
70+ 	} 
71+ 
6772	useEffect (  ( )  =>  { 
6873		/** 
6974		 * Keep the lock refreshed. 
@@ -96,6 +101,12 @@ function PostLockedModal() {
96101
97102			const  received  =  data [  'wp-refresh-post-lock'  ] ; 
98103			if  (  received . lock_error  )  { 
104+ 				// If both the current user and the lock owner can collaboratively 
105+ 				// edit, do not enforce the takeover. 
106+ 				if  (  syncEnabled  &&  received . lock_error . syncEnabled  )  { 
107+ 					return ; 
108+ 				} 
109+ 
99110				// Auto save and display the takeover modal. 
100111				autosave ( ) ; 
101112				updatePostLock (  { 
@@ -154,11 +165,10 @@ function PostLockedModal() {
154165		return  null ; 
155166	} 
156167
157- 	// Avoid sending the modal if sync is supported, but retain functionality around locks etc. 
158- 	if  (  window . __experimentalEnableSync  &&  supportsSync  )  { 
159- 		if  (  globalThis . IS_GUTENBERG_PLUGIN  )  { 
160- 			return  null ; 
161- 		} 
168+ 	// If both the current user and the lock owner can collaboratively edit, do not 
169+ 	// show the modal. 
170+ 	if  (  syncEnabled  &&  user . syncEnabled  )  { 
171+ 		return  null ; 
162172	} 
163173
164174	const  userDisplayName  =  user . name ; 
0 commit comments