Skip to content

Commit

Permalink
fix(stronghold): remove constructor, add static load function (tauri-…
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog authored and OrIOg committed Jun 25, 2023
1 parent 22a331c commit 0b6228e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changes/stronghold-constructor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"stronghold-js": minor
---

Added `Stronghold.load` and removed its constructor.
11 changes: 5 additions & 6 deletions plugins/stronghold/guest-js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,21 +395,20 @@ export class Stronghold {
* @param path
* @param password
*/
constructor(path: string, password: string) {
private constructor(path: string) {
this.path = path;
void this.reload(password);
}

/**
* Force a reload of the snapshot. The password must match.
* Load the snapshot if it exists (password must match), or start a fresh stronghold instance otherwise.
* @param password
* @returns
*/
private async reload(password: string): Promise<void> {
static async load(path: string, password: string): Promise<Stronghold> {
return await invoke("plugin:stronghold|initialize", {
snapshotPath: this.path,
snapshotPath: path,
password,
});
}).then(() => new Stronghold(path));
}

/**
Expand Down

0 comments on commit 0b6228e

Please sign in to comment.