Skip to content

Commit

Permalink
fix(window-state): propagate promise (tauri-apps#435)
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir authored and OrIOg committed Jun 25, 2023
1 parent 6eff65d commit 29cb373
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changes/window-state-promise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"window-state-js": "patch"
---

Correctly propagate the promise inside `saveWindowState`, `restoreState` and `restoreStateCurrent` so callers can choose to `await` them.
15 changes: 9 additions & 6 deletions plugins/window-state/guest-js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,25 @@ export enum StateFlags {
/**
* Save the state of all open windows to disk.
*/
async function saveWindowState(flags: StateFlags) {
invoke("plugin:window-state|save_window_state", { flags });
async function saveWindowState(flags: StateFlags): Promise<void> {
return invoke("plugin:window-state|save_window_state", { flags });
}

/**
* Restore the state for the specified window from disk.
*/
async function restoreState(label: WindowLabel, flags: StateFlags) {
invoke("plugin:window-state|restore_state", { label, flags });
async function restoreState(
label: WindowLabel,
flags: StateFlags
): Promise<void> {
return invoke("plugin:window-state|restore_state", { label, flags });
}

/**
* Restore the state for the current window from disk.
*/
async function restoreStateCurrent(flags: StateFlags) {
restoreState(getCurrent().label, flags);
async function restoreStateCurrent(flags: StateFlags): Promise<void> {
return restoreState(getCurrent().label, flags);
}

export { restoreState, restoreStateCurrent, saveWindowState };

0 comments on commit 29cb373

Please sign in to comment.