Skip to content

Commit

Permalink
fix: attempt to use reactivity to resize window
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisakura committed Aug 29, 2023
1 parent ebd0d32 commit a9bd403
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
19 changes: 16 additions & 3 deletions frontend/src/components/installer/FailureModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import * as Installer from "../../../wailsjs/go/installer/Installer.js";
import Heading from "../text/Heading.svelte";
import Button from "../Button.svelte";
import { closeWindow } from "../windows/index.js";
import { closeWindow, resizeWindow } from "../windows/index.js";
import { BrowserOpenURL } from "../../../wailsjs/runtime/runtime.js";
import * as IPC from "./ipc";
Expand All @@ -26,16 +26,29 @@
setTimeout(() => IPC.doAction(op, path, onAction));
}
let isOwned = true;
// svelte hacks...
async function CheckOwnership() {
isOwned = await Installer.CheckForOwnershipDarwin(path);
}
$: if (!isOwned) {
resizeWindow(_windowId, 450, 510);
} else {
resizeWindow(_windowId, 450, 200);
}
</script>

<section role="dialog">
<Heading tag="h6" --color="var(--accent-red)">Oh no!</Heading>
<p>Something went wrong!</p>
{#if message}
{#if message.includes("file exists") || message.includes("permission denied")}
{#await Installer.CheckForOwnershipDarwin(path)}
{#await CheckOwnership()}
<p>{message}</p>
{:then isOwned}
{:then}
{#if !isOwned}
<p>Hmm... seems like you've encountered a Mac-specific problem! Usually, this is one of two things:</p>
<p>
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/components/windows/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ export const closeWindow = (id: string) => {
});
};

export const resizeWindow = (id: string, w: number, h: number) => {
windowStore.update(windows => {
windows[id].props.width = w;
windows[id].props.height = h;
return windows;
});
}

let zIndex = 0;
export const getFocusZIndex = () => {
zIndex++;
Expand Down

0 comments on commit a9bd403

Please sign in to comment.