Skip to content

Commit 2aca57a

Browse files
committed
fix creating community on mobile
1 parent c7d4c14 commit 2aca57a

1 file changed

Lines changed: 21 additions & 19 deletions

File tree

packages/backend/src/nest/qss/qss.service.ts

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,6 @@ export class QSSService extends EventEmitter implements OnModuleDestroy, OnModul
448448
}
449449
}
450450

451-
await this.emitNseQssUrl(this._qssEndpoint)
452-
453451
// wait for our socket to finish connecting
454452
let connStatus: QSSOperationResult
455453
try {
@@ -488,27 +486,30 @@ export class QSSService extends EventEmitter implements OnModuleDestroy, OnModul
488486
if ((process.platform as string) !== 'ios') {
489487
return
490488
}
489+
try {
490+
const community = await this.localDbService.getCurrentCommunity()
491+
const teamId = community?.teamId ?? this.sigChainService.getActiveChain(false)?.team?.id
492+
if (teamId == null) {
493+
this.logger.warn('Skipping NSE QSS URL update because no active community or team ID found')
494+
this.logger.warn('Community', community)
495+
return
496+
}
491497

492-
const community = await this.localDbService.getCurrentCommunity()
493-
const teamId = community?.teamId ?? this.sigChainService.team?.id
494-
if (teamId == null) {
495-
this.logger.warn('Skipping NSE QSS URL update because no active community or team ID found')
496-
this.logger.warn('Community', community)
497-
return
498-
}
498+
const qssUrl = this.getNseQssUrl(wsUrl)
499+
if (qssUrl == null) {
500+
this.logger.warn('Skipping NSE QSS URL update because no valid QSS URL could be derived')
501+
return
502+
}
499503

500-
const qssUrl = this.getNseQssUrl(wsUrl)
501-
if (qssUrl == null) {
502-
this.logger.warn('Skipping NSE QSS URL update because no valid QSS URL could be derived')
503-
return
504-
}
504+
const payload: NseQssUrlUpdatedEvent = {
505+
teamId,
506+
qssUrl,
507+
}
505508

506-
const payload: NseQssUrlUpdatedEvent = {
507-
teamId,
508-
qssUrl,
509+
this.socketService.serverIoProvider.io.emit(SocketEvents.NSE_QSS_URL_UPDATED, payload)
510+
} catch (e) {
511+
this.logger.error('Failed to emit NSE QSS URL update', e)
509512
}
510-
511-
this.socketService.serverIoProvider.io.emit(SocketEvents.NSE_QSS_URL_UPDATED, payload)
512513
}
513514

514515
/**
@@ -708,6 +709,7 @@ export class QSSService extends EventEmitter implements OnModuleDestroy, OnModul
708709

709710
if (result === QSSOperationResult.SUCCESS) {
710711
this.logger.info('Successfully signed in to QSS, starting periodic log pulls once connected', teamId)
712+
await this.emitNseQssUrl(this._qssEndpoint)
711713
const authConnection = this.qssAuthConnManager.getConnection(teamId)
712714
const startLogPullInterval = (): void => {
713715
if (sigChain.team != null && !sigChain.roles.amIMemberOfRole(RoleName.MEMBER)) {

0 commit comments

Comments
 (0)