@@ -34,6 +34,7 @@ import Flex from "antd/es/flex";
34
34
import React from "react" ;
35
35
import dayjs from "dayjs" ;
36
36
import { currentApplication } from "@lowcoder-ee/redux/selectors/applicationSelector" ;
37
+ import { notificationInstance } from "components/GlobalInstances" ;
37
38
38
39
const AppSnapshot = lazy ( ( ) => {
39
40
return import ( "pages/editor/appSnapshot" )
@@ -115,10 +116,8 @@ const AppEditor = React.memo(() => {
115
116
if ( currentUser && application ) {
116
117
const lastEditedAt = dayjs ( application ?. lastEditedAt ) ;
117
118
const lastEditedDiff = dayjs ( ) . diff ( lastEditedAt , 'minutes' ) ;
118
- // const shouldBlockEditing = currentUser.id !== application?.createBy && lastEditedDiff < 5;
119
- const shouldBlockEditing = lastEditedDiff < 5 ;
119
+ const shouldBlockEditing = currentUser . id !== application ?. editingUserId && lastEditedDiff < 3 ;
120
120
setBlockEditing ( shouldBlockEditing ) ;
121
- console . log ( 'blockEditing' , shouldBlockEditing , { user_id : currentUser . id , editingUserId : application . createBy , lastEditedDiff} ) ;
122
121
}
123
122
} , [ application , currentUser ] ) ;
124
123
@@ -189,15 +188,21 @@ const AppEditor = React.memo(() => {
189
188
fetchApplication ( ) ;
190
189
} , [ fetchApplication ] ) ;
191
190
192
- // useEffect(() => {
193
- // if(!blockEditing) return clearInterval(fetchInterval.current);
194
- // if(blockEditing) {
195
- // fetchInterval.current = window.setInterval(() => {
196
- // fetchApplication();
197
- // }, 60000);
198
- // }
199
- // return () => clearInterval(fetchInterval.current);
200
- // }, [blockEditing, fetchApplication]);
191
+ useEffect ( ( ) => {
192
+ if ( ! blockEditing && fetchInterval . current ) {
193
+ notificationInstance . info ( {
194
+ message : 'Editing Enabled' ,
195
+ description : 'Editing is now enabled. You can proceed with your changes.'
196
+ } ) ;
197
+ return clearInterval ( fetchInterval . current ) ;
198
+ }
199
+ if ( blockEditing ) {
200
+ fetchInterval . current = window . setInterval ( ( ) => {
201
+ fetchApplication ( ) ;
202
+ } , 60000 ) ;
203
+ }
204
+ return ( ) => clearInterval ( fetchInterval . current ) ;
205
+ } , [ blockEditing , fetchApplication ] ) ;
201
206
202
207
const fallbackUI = useMemo ( ( ) => (
203
208
< Flex align = "center" justify = "center" vertical style = { {
0 commit comments