|
5 | 5 | -->
|
6 | 6 |
|
7 | 7 | <script lang="ts">
|
8 |
| - import { Environment, BrowserOpenURL } from "../../../wailsjs/runtime/runtime.js"; |
9 | 8 | import * as Installer from "../../../wailsjs/go/installer/Installer.js";
|
10 | 9 | import SuccessModal from "./SuccessModal.svelte";
|
11 | 10 | import Heading from "../text/Heading.svelte";
|
12 | 11 | import Button from "../Button.svelte";
|
13 | 12 | import { closeWindow, openWindow } from "../windows/index.js";
|
| 13 | + import { BrowserOpenURL } from "../../../wailsjs/runtime/runtime.js"; |
14 | 14 |
|
15 | 15 | type IPCCall = (typeof Installer)["Patch" | "Repair" | "Unpatch" | "InstallOpenAsar" | "UninstallOpenAsar"];
|
16 | 16 |
|
|
19 | 19 | export let op: IPCCall;
|
20 | 20 | export let getOpPastTense: (IPCCall) => string;
|
21 | 21 | export let onAction: () => void;
|
| 22 | + export let _windowId: string; |
22 | 23 |
|
23 | 24 | async function runAndShowSuccess() {
|
24 |
| - await op(path); |
25 |
| - openWindow( |
26 |
| - SuccessModal, |
27 |
| - { |
28 |
| - verb: getOpPastTense(op) |
29 |
| - }, |
30 |
| - { |
31 |
| - title: "Success", |
32 |
| - width: 400, |
33 |
| - height: 510 |
34 |
| - } |
35 |
| - ); |
36 |
| - // closeWindow(id); |
37 |
| - onAction(); |
38 |
| - } |
| 25 | + if (!await Installer.PromptForChown(path)) return; |
39 | 26 |
|
40 |
| - let buttonPress: () => void; |
| 27 | + closeWindow(_windowId); |
41 | 28 |
|
42 |
| - function waitForButton() { |
43 |
| - return new Promise<void>(res => { |
44 |
| - buttonPress = res; |
| 29 | + setTimeout(async () => { |
| 30 | + await op(path); |
| 31 | + openWindow( |
| 32 | + SuccessModal, |
| 33 | + { |
| 34 | + verb: getOpPastTense(op) |
| 35 | + }, |
| 36 | + { |
| 37 | + title: "Woohoo!", |
| 38 | + width: 400, |
| 39 | + height: 510 |
| 40 | + } |
| 41 | + ); |
| 42 | + onAction(); |
45 | 43 | });
|
46 | 44 | }
|
47 | 45 | </script>
|
48 | 46 |
|
49 | 47 | <section role="dialog">
|
50 | 48 | <Heading tag="h6" --color="var(--accent-red)">Oh no!</Heading>
|
51 |
| - <p>Unable to do the thing u were trying to do :(((((</p> |
| 49 | + <p>Something went wrong!</p> |
52 | 50 | {#if message}
|
53 | 51 | {#if message.includes("file exists") || message.includes("permission denied")}
|
54 | 52 | {#await Installer.CheckForOwnershipDarwin(path)}
|
55 | 53 | <p>{message}</p>
|
56 | 54 | {:then isOwned}
|
57 | 55 | {#if !isOwned}
|
58 |
| - {#await Environment()} |
59 |
| - <p>{message}</p> |
60 |
| - {:then env} |
61 |
| - {#if env.platform === "darwin"} |
62 |
| - {#await waitForButton()} |
63 |
| - <p>Please allow vencord to fix discord's permissions</p> |
64 |
| - <Button on:click={buttonPress}>Try again as admin</Button> |
65 |
| - {:then} |
66 |
| - {#await Installer.PromptForChown(path)} |
67 |
| - <p>Please allow vencord to fix discord's permissions</p> |
68 |
| - <Button on:click={() => {}}>Try again as admin</Button> |
69 |
| - {:then} |
70 |
| - {#await runAndShowSuccess()} |
71 |
| - <p>Working...</p> |
72 |
| - {:then} |
73 |
| - <p>Success! You can close this window</p> |
74 |
| - {:catch} |
75 |
| - <p>Please grant the installer full disk access</p> |
76 |
| - <Button |
77 |
| - on:click={() => |
78 |
| - BrowserOpenURL( |
79 |
| - "x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles" |
80 |
| - )}>Open Security Settings</Button |
81 |
| - > |
82 |
| - {/await} |
83 |
| - {:catch error} |
84 |
| - <p>{error}</p> |
85 |
| - {/await} |
86 |
| - {/await} |
87 |
| - {:else} |
88 |
| - <p>{message}</p> |
89 |
| - {/if} |
90 |
| - {/await} |
| 56 | + <p>Hmm... seems like you've encountered a Mac-specific problem! Usually, this is one of two things:</p> |
| 57 | + <ul> |
| 58 | + <li> |
| 59 | + <p> |
| 60 | + Your Discord installation's permissions appear to be broken. Luckily, we offer a simple |
| 61 | + tool to fix this. |
| 62 | + </p> |
| 63 | + <Button on:click={runAndShowSuccess}>Repair Permissions</Button> |
| 64 | + </li> |
| 65 | + <li> |
| 66 | + <p> |
| 67 | + Sometimes the installer needs Full Disk Access, though usually the above should suffice. |
| 68 | + </p> |
| 69 | + <Button on:click={() => |
| 70 | + BrowserOpenURL("x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles")}> |
| 71 | + Open Security Settings |
| 72 | + </Button> |
| 73 | + </li> |
| 74 | + </ul> |
91 | 75 | {:else}
|
92 | 76 | <p>{message}</p>
|
93 | 77 | {/if}
|
|
0 commit comments