File tree Expand file tree Collapse file tree
design/nodejshelpertheme/js Expand file tree Collapse file tree Original file line number Diff line number Diff line change 129129 setInterval ( function ( ) {
130130 nodejshelper . syncbackoffice ( 'snow' ) ;
131131 } , ( nodejshelperConfig . online_timeout - 10 ) * 1000 ) ;
132+
133+ setInterval ( function ( ) {
134+ nodejshelper . syncbackofficechats ( ) ;
135+ } , 10000 ) ;
136+
132137 } catch ( err ) {
133138 //
134139 } ;
244249 }
245250 } ,
246251
252+ canSyncBackOffice : true ,
253+ canSyncBackOfficeTimeout : true ,
254+
255+ syncbackofficechats : function ( ) {
256+ if ( this . canSyncBackOffice == true ) {
257+ lhinst . syncadmincall ( ) ;
258+ }
259+ } ,
260+
247261 userjoined : function ( chat_id ) {
248262 if ( nodejshelper . isConnected == true ) {
249263 setTimeout ( function ( ) {
320334
321335 syncadmincall : function ( inst , data ) {
322336 if ( nodejshelper . isConnected == true ) {
323- clearTimeout ( inst . userTimeout ) ;
337+ clearTimeout ( inst . userTimeout ) ;
338+ clearTimeout ( nodejshelper . canSyncBackOfficeTimeout ) ;
339+
340+ // Enable automatic back office sync only after 30 seconds
341+ nodejshelper . canSyncBackOffice = false ;
342+ nodejshelper . canSyncBackOfficeTimeout = setTimeout ( function ( ) {
343+ nodejshelper . canSyncBackOffice = true ;
344+ } , 30000 ) ;
324345 }
325346 } ,
326347
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ io.sockets.on('connection', function (socket) {
3636 redisClient = redis . createClient ( config . redis . port , config . redis . host , config . redis . options ) ;
3737
3838 redisClient . on ( "message" , function ( channel , message ) {
39- if ( channel . indexOf ( 'admin_room_' ) !== - 1 ) {
39+ if ( channel . indexOf ( 'admin_room_' ) !== - 1 ) {
4040 socket . emit ( 'syncbackoffice' , message ) ;
4141 } else {
4242 socket . emit ( 'syncforce' , message ) ;
@@ -164,7 +164,7 @@ io.sockets.on('connection', function (socket) {
164164 socket . emit ( 'syncbackoffice' , message ) ;
165165 } ) ;
166166 } ;
167- redisClient . subscribe ( 'admin_room_' + data . instance_id ) ;
167+ redisClient . subscribe ( 'admin_room_' + data . instance_id ) ;
168168 }
169169 } catch ( e ) {
170170 if ( config . debug . output == true ) {
You can’t perform that action at this time.
0 commit comments