Skip to content

Commit

Permalink
fix: prevent duplicate launch calls (#1867)
Browse files Browse the repository at this point in the history
  • Loading branch information
moughxyz committed Oct 24, 2022
1 parent a96323d commit 4928df0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/snjs/lib/Application/Application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
* This function will load all services in their correct order.
*/
async prepareForLaunch(callback: LaunchCallback): Promise<void> {
if (this.launched) {
throw new Error('Attempting to prelaunch already launched application')
}

await this.options.crypto.initialize()

this.setLaunchCallback(callback)
Expand Down Expand Up @@ -323,6 +327,10 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
* Option to await database load before marking the app as ready.
*/
public async launch(awaitDatabaseLoad = false): Promise<void> {
if (this.launched) {
throw new Error('Attempting to launch already launched application')
}

this.launched = false

const launchChallenge = this.getLaunchChallenge()
Expand Down

0 comments on commit 4928df0

Please sign in to comment.