Reset button for HTTP proxy

This commit is contained in:
rift 2024-01-15 10:30:21 -06:00
parent 2c22a6afc6
commit fbff40d7f8

View file

@ -14,6 +14,14 @@ function ProxyInput(props: BareInputProps) {
const bareServer = localStorage.getItem("bare") || "/bare/"; const bareServer = localStorage.getItem("bare") || "/bare/";
const HTTPProxy = localStorage.getItem("HTTPProxy") || ""; const HTTPProxy = localStorage.getItem("HTTPProxy") || "";
const [inputValue, setInputValue] = useState(HTTPProxy); const [inputValue, setInputValue] = useState(HTTPProxy);
function resetProxy() {
set("HTTPProxy", "");
localStorage.setItem("HTTPProxy", "");
uninstallServiceWorkers();
window.location.reload();
}
function validateUrl(url: string) { function validateUrl(url: string) {
let finalUrl = url; let finalUrl = url;
@ -56,10 +64,10 @@ function ProxyInput(props: BareInputProps) {
response.headers.get("x-bare-status") === "302" response.headers.get("x-bare-status") === "302"
) { ) {
// Success! // Success!
set("HTTPProxy", proxyUrl); set("HTTPProxy", proxyUrl);
localStorage.setItem("HTTPProxy", proxyUrl); localStorage.setItem("HTTPProxy", proxyUrl);
uninstallServiceWorkers(); uninstallServiceWorkers();
window.location.reload(); window.location.reload();
return true; return true;
} else { } else {
( (
@ -110,11 +118,19 @@ function ProxyInput(props: BareInputProps) {
id="pinput" id="pinput"
className="font-roboto flex h-14 w-56 flex-row rounded-2xl border border-input-border-color bg-input p-4 text-center text-sm" className="font-roboto flex h-14 w-56 flex-row rounded-2xl border border-input-border-color bg-input p-4 text-center text-sm"
/> />
<div <div class="flex flex-row gap-4">
className="font-roboto mt-2 flex h-4 w-36 cursor-pointer flex-row items-center justify-center rounded-xl border border-input-border-color bg-input p-5 text-center text-lg" <div
onClick={handleChange} className="font-roboto mt-2 flex h-4 w-36 cursor-pointer flex-row items-center justify-center rounded-xl border border-input-border-color bg-input p-5 text-center text-lg"
> onClick={handleChange}
{t("settings.bare.select")} >
{t("settings.bare.select")}
</div>
<div
className="font-roboto mt-2 flex h-4 w-36 cursor-pointer flex-row items-center justify-center rounded-xl border border-input-border-color bg-input p-5 text-center text-lg"
onClick={resetProxy}
>
Reset
</div>
</div> </div>
</div> </div>
</div> </div>