Skip to content

Commit

Permalink
Fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Leblow committed May 7, 2024
1 parent bf0ebb5 commit f7b370c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,11 @@ export class ConnectionsManagerService extends EventEmitter implements OnModuleI
}
}

public async closeAllServices(options: { saveTor: boolean } = { saveTor: false }) {
public async closeAllServices(
options: { saveTor: boolean; purgeLocalDb: boolean } = { saveTor: false, purgeLocalDb: false }
) {
this.logger('Closing services')

await this.closeSocket()

if (this.tor && !options.saveTor) {
Expand All @@ -241,7 +245,11 @@ export class ConnectionsManagerService extends EventEmitter implements OnModuleI
await this.libp2pService.close()
}
if (this.localDbService) {
this.logger('Closing local storage')
if (options.purgeLocalDb) {
this.logger('Purging local DB')
await this.localDbService.purge()
}
this.logger('Closing local DB')
await this.localDbService.close()
}
}
Expand Down Expand Up @@ -285,31 +293,14 @@ export class ConnectionsManagerService extends EventEmitter implements OnModuleI
public async leaveCommunity() {
this.logger('Running leaveCommunity')

await this.closeSocket()

if (this.storageService) {
this.logger('Stopping OrbitDB')
await this.storageService.stopOrbitDb()
}

if (this.libp2pService) {
this.logger('Stopping libp2p')
await this.libp2pService.close()
}

if (this.localDbService) {
this.logger('Purging local DB')
await this.localDbService.purge()
this.logger('Closing local DB')
await this.localDbService.close()
}

this.logger('Resetting tor')
this.tor.resetHiddenServices()
await this.closeAllServices({ saveTor: true, purgeLocalDb: true })

this.logger('Purging data')
await this.purgeData()

this.logger('Resetting Tor')
this.tor.resetHiddenServices()

this.logger('Resetting state')
await this.resetState()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { io } from 'socket.io-client'
import {
select,
put,
putResolve,
call,
cancel,
fork,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { select, call, put } from 'typed-redux-saga'
import { select, call, putResolve } from 'typed-redux-saga'
import { app } from '@quiet/state-manager'
import { persistor } from '../../store'
import { nativeServicesActions } from '../nativeServices.slice'
Expand Down

0 comments on commit f7b370c

Please sign in to comment.