web: remove instance override warning, use custom api right away

This commit is contained in:
wukko 2024-11-18 16:32:33 +06:00
parent 2b2bc57331
commit d8348dfa1c
No known key found for this signature in database
GPG key ID: 3E30B3F26C7B4AA2
5 changed files with 1 additions and 86 deletions

View file

@ -113,10 +113,6 @@
"advanced.data": "data management",
"processing.override": "default instance override",
"processing.override.title": "use the instance-provided processing server",
"processing.override.description": "if web instance provides its own default processing server, you can choose to use it over the main processing server. make sure it's a server by someone you trust.",
"processing.community": "community instances",
"processing.enable_custom.title": "use a custom processing server",

View file

@ -10,7 +10,7 @@ export const currentApiURL = () => {
return new URL(customInstanceURL).origin;
}
if (env.DEFAULT_API && processingSettings.allowDefaultOverride) {
if (env.DEFAULT_API) {
return new URL(env.DEFAULT_API).origin;
}

View file

@ -6,7 +6,6 @@ import lazySettingGetter from "$lib/settings/lazy-get";
import { getSession } from "$lib/api/session";
import { currentApiURL } from "$lib/api/api-url";
import { turnstileLoaded } from "$lib/state/turnstile";
import { apiOverrideWarning } from "$lib/api/safety-warning";
import { cachedInfo, getServerInfo } from "$lib/api/server-info";
import type { Optional } from "$lib/types/generic";
@ -37,8 +36,6 @@ const request = async (url: string) => {
alwaysProxy: getSetting("privacy", "alwaysProxy"),
}
await apiOverrideWarning();
await getServerInfo();
const getCachedInfo = get(cachedInfo);

View file

@ -1,68 +1,9 @@
import { get } from "svelte/store";
import env from "$lib/env";
import { t } from "$lib/i18n/translations";
import settings, { updateSetting } from "$lib/state/settings";
import { createDialog } from "$lib/state/dialogs";
export const apiOverrideWarning = async () => {
if (!env.DEFAULT_API || get(settings).processing.seenOverrideWarning) {
return;
}
let _actions: {
resolve: () => void;
reject: () => void;
};
const promise = new Promise<void>(
(resolve, reject) => (_actions = { resolve, reject })
).catch(() => {
return {}
});
createDialog({
id: "security-api-override",
type: "small",
icon: "warn-red",
title: get(t)("dialog.api.override.title"),
bodyText: get(t)("dialog.api.override.body", { value: env.DEFAULT_API }),
dismissable: false,
buttons: [
{
text: get(t)("button.cancel"),
main: false,
action: () => {
_actions.reject();
updateSetting({
processing: {
seenOverrideWarning: true,
},
})
},
},
{
text: get(t)("button.continue"),
color: "red",
main: true,
timeout: 5000,
action: () => {
_actions.resolve();
updateSetting({
processing: {
allowDefaultOverride: true,
seenOverrideWarning: true,
},
})
},
},
],
})
await promise;
}
export const customInstanceWarning = async () => {
if (get(settings).processing.seenCustomWarning) {
return;

View file

@ -1,5 +1,4 @@
<script lang="ts">
import env from "$lib/env";
import settings from "$lib/state/settings";
import { t } from "$lib/i18n/translations";
@ -7,26 +6,8 @@
import SettingsToggle from "$components/buttons/SettingsToggle.svelte";
import SettingsCategory from "$components/settings/SettingsCategory.svelte";
import CustomInstanceInput from "$components/settings/CustomInstanceInput.svelte";
$: overrideDisabled = $settings.processing.enableCustomInstances;
</script>
{#if env.DEFAULT_API}
<SettingsCategory
sectionId="override"
title={$t("settings.processing.override")}
disabled={overrideDisabled}
>
<SettingsToggle
settingContext="processing"
settingId="allowDefaultOverride"
title={$t("settings.processing.override.title")}
description={$t("settings.processing.override.description")}
disabled={overrideDisabled}
/>
</SettingsCategory>
{/if}
<SettingsCategory
sectionId="community"
title={$t("settings.processing.community")}