@@ -107,7 +107,7 @@ export class InstanceController {
107107 if ( qrcode ) {
108108 this . logger . verbose ( 'creating qrcode' ) ;
109109 await instance . connectToWhatsapp ( number ) ;
110- await delay ( 3000 ) ;
110+ await delay ( 5000 ) ;
111111 getQrcode = instance . qrCode ;
112112 }
113113
@@ -214,7 +214,7 @@ export class InstanceController {
214214 this . logger . verbose ( 'connecting' ) ;
215215 await instance . connectToWhatsapp ( number ) ;
216216
217- await delay ( 2000 ) ;
217+ await delay ( 5000 ) ;
218218 return instance . qrCode ;
219219 }
220220
@@ -245,7 +245,12 @@ export class InstanceController {
245245
246246 public async connectionState ( { instanceName } : InstanceDto ) {
247247 this . logger . verbose ( 'requested connectionState from ' + instanceName + ' instance' ) ;
248- return this . waMonitor . waInstances [ instanceName ] ?. connectionStatus ;
248+ return {
249+ instance : {
250+ instanceName : instanceName ,
251+ state : this . waMonitor . waInstances [ instanceName ] ?. connectionStatus ?. state ,
252+ } ,
253+ } ;
249254 }
250255
251256 public async fetchInstances ( { instanceName } : InstanceDto ) {
@@ -260,9 +265,9 @@ export class InstanceController {
260265
261266 public async logout ( { instanceName } : InstanceDto ) {
262267 this . logger . verbose ( 'requested logout from ' + instanceName + ' instance' ) ;
263- const stateConn = await this . connectionState ( { instanceName } ) ;
268+ const { instance } = await this . connectionState ( { instanceName } ) ;
264269
265- if ( stateConn . state === 'close' ) {
270+ if ( instance . state === 'close' ) {
266271 throw new BadRequestException (
267272 'The "' + instanceName + '" instance is not connected' ,
268273 ) ;
@@ -285,15 +290,15 @@ export class InstanceController {
285290
286291 public async deleteInstance ( { instanceName } : InstanceDto ) {
287292 this . logger . verbose ( 'requested deleteInstance from ' + instanceName + ' instance' ) ;
288- const stateConn = await this . connectionState ( { instanceName } ) ;
293+ const { instance } = await this . connectionState ( { instanceName } ) ;
289294
290- if ( stateConn . state === 'open' ) {
295+ if ( instance . state === 'open' ) {
291296 throw new BadRequestException (
292297 'The "' + instanceName + '" instance needs to be disconnected' ,
293298 ) ;
294299 }
295300 try {
296- if ( stateConn . state === 'connecting' ) {
301+ if ( instance . state === 'connecting' ) {
297302 this . logger . verbose ( 'logging out instance: ' + instanceName ) ;
298303
299304 await this . logout ( { instanceName } ) ;
0 commit comments