76 lines
2.9 KiB
TypeScript
76 lines
2.9 KiB
TypeScript
/*
|
|
* SPDX-License-Identifier: GPL-3.0
|
|
* Vesktop, a desktop app aiming to give you a snappier Discord Experience
|
|
* Copyright (c) 2023 Vendicated and Vencord contributors
|
|
*/
|
|
|
|
import { useForceUpdater } from "@vencord/types/utils";
|
|
import { Button, Forms, Toasts } from "@vencord/types/webpack/common";
|
|
|
|
import { SettingsComponent } from "./Settings";
|
|
|
|
export const VencordLocationPicker: SettingsComponent = ({ settings }) => {
|
|
const forceUpdate = useForceUpdater();
|
|
const vencordDir = VesktopNative.fileManager.getVencordDir();
|
|
|
|
return (
|
|
<>
|
|
<Forms.FormText>
|
|
Vencord files are loaded from{" "}
|
|
{vencordDir ? (
|
|
<a
|
|
href="about:blank"
|
|
onClick={e => {
|
|
e.preventDefault();
|
|
VesktopNative.fileManager.showItemInFolder(vencordDir!);
|
|
}}
|
|
>
|
|
{vencordDir}
|
|
</a>
|
|
) : (
|
|
"the default location"
|
|
)}
|
|
</Forms.FormText>
|
|
<div className="vcd-location-btns">
|
|
<Button
|
|
size={Button.Sizes.SMALL}
|
|
onClick={async () => {
|
|
const choice = await VesktopNative.fileManager.selectVencordDir();
|
|
switch (choice) {
|
|
case "cancelled":
|
|
break;
|
|
case "ok":
|
|
Toasts.show({
|
|
message: "Vencord install changed. Fully restart Vesktop to apply.",
|
|
id: Toasts.genId(),
|
|
type: Toasts.Type.SUCCESS
|
|
});
|
|
break;
|
|
case "invalid":
|
|
Toasts.show({
|
|
message:
|
|
"You did not choose a valid Vencord install. Make sure you're selecting the dist dir!",
|
|
id: Toasts.genId(),
|
|
type: Toasts.Type.FAILURE
|
|
});
|
|
break;
|
|
}
|
|
forceUpdate();
|
|
}}
|
|
>
|
|
Change
|
|
</Button>
|
|
<Button
|
|
size={Button.Sizes.SMALL}
|
|
color={Button.Colors.RED}
|
|
onClick={async () => {
|
|
await VesktopNative.fileManager.selectVencordDir(null);
|
|
forceUpdate();
|
|
}}
|
|
>
|
|
Reset
|
|
</Button>
|
|
</div>
|
|
</>
|
|
);
|
|
};
|