Merge branch 'v1' into stronghold/plugin-review

pull/415/head
Alexandre Dang 2 years ago committed by GitHub
commit 0c16b4702e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,5 @@
---
"stronghold-js": minor
---
Added `Stronghold.load` and removed its constructor.

@ -405,22 +405,20 @@ export class Stronghold {
* @param path * @param path
* @param password * @param password
*/ */
static async init(path: string, password: string): Promise<Stronghold> { private constructor(path: string) {
let stronghold = new Stronghold(path); this.path = path;
await stronghold.reload(password);
return stronghold;
} }
/** /**
* 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 * @param password
* @returns * @returns
*/ */
private async reload(password: string): Promise<void> { static async load(path: string, password: string): Promise<Stronghold> {
return await invoke("plugin:stronghold|initialize", { return await invoke("plugin:stronghold|initialize", {
snapshotPath: this.path, snapshotPath: path,
password, password,
}); }).then(() => new Stronghold(path));
} }
/** /**

Loading…
Cancel
Save