fix(window-state): propagate promise (#435)

closes #432
pull/436/head
Amr Bashir 2 years ago committed by amrbashir
parent 48d11d50a8
commit 38e8522be5
No known key found for this signature in database
GPG Key ID: BBD7A47A2003FF33

@ -0,0 +1,5 @@
---
"window-state-js": "patch"
---
Correctly propagate the promise inside `saveWindowState`, `restoreState` and `restoreStateCurrent` so callers can choose to `await` them.

@ -34,15 +34,17 @@ export enum StateFlags {
/**
* Save the state of all open windows to disk.
*/
async function saveWindowState(flags: StateFlags) {
window.__TAURI_INVOKE__("plugin:window-state|save_window_state", { flags });
async function saveWindowState(flags: StateFlags): Promise<void> {
return window.__TAURI_INVOKE__("plugin:window-state|save_window_state", {
flags,
});
}
/**
* Restore the state for the specified window from disk.
*/
async function restoreState(label: string, flags: StateFlags) {
window.__TAURI_INVOKE__("plugin:window-state|restore_state", {
async function restoreState(label: string, flags: StateFlags): Promise<void> {
return window.__TAURI_INVOKE__("plugin:window-state|restore_state", {
label,
flags,
});
@ -51,8 +53,8 @@ async function restoreState(label: string, flags: StateFlags) {
/**
* Restore the state for the current window from disk.
*/
async function restoreStateCurrent(flags: StateFlags) {
restoreState(window.__TAURI_METADATA__.__currentWindow.label, flags);
async function restoreStateCurrent(flags: StateFlags): Promise<void> {
return restoreState(window.__TAURI_METADATA__.__currentWindow.label, flags);
}
export { restoreState, restoreStateCurrent, saveWindowState };

Loading…
Cancel
Save