mirror of
https://github.com/imputnet/cobalt.git
synced 2025-02-05 13:08:40 +00:00
web: remove instance override warning, use custom api right away
This commit is contained in:
parent
2b2bc57331
commit
d8348dfa1c
|
@ -113,10 +113,6 @@
|
||||||
|
|
||||||
"advanced.data": "data management",
|
"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.community": "community instances",
|
||||||
|
|
||||||
"processing.enable_custom.title": "use a custom processing server",
|
"processing.enable_custom.title": "use a custom processing server",
|
||||||
|
|
|
@ -10,7 +10,7 @@ export const currentApiURL = () => {
|
||||||
return new URL(customInstanceURL).origin;
|
return new URL(customInstanceURL).origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (env.DEFAULT_API && processingSettings.allowDefaultOverride) {
|
if (env.DEFAULT_API) {
|
||||||
return new URL(env.DEFAULT_API).origin;
|
return new URL(env.DEFAULT_API).origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ import lazySettingGetter from "$lib/settings/lazy-get";
|
||||||
import { getSession } from "$lib/api/session";
|
import { getSession } from "$lib/api/session";
|
||||||
import { currentApiURL } from "$lib/api/api-url";
|
import { currentApiURL } from "$lib/api/api-url";
|
||||||
import { turnstileLoaded } from "$lib/state/turnstile";
|
import { turnstileLoaded } from "$lib/state/turnstile";
|
||||||
import { apiOverrideWarning } from "$lib/api/safety-warning";
|
|
||||||
import { cachedInfo, getServerInfo } from "$lib/api/server-info";
|
import { cachedInfo, getServerInfo } from "$lib/api/server-info";
|
||||||
|
|
||||||
import type { Optional } from "$lib/types/generic";
|
import type { Optional } from "$lib/types/generic";
|
||||||
|
@ -37,8 +36,6 @@ const request = async (url: string) => {
|
||||||
alwaysProxy: getSetting("privacy", "alwaysProxy"),
|
alwaysProxy: getSetting("privacy", "alwaysProxy"),
|
||||||
}
|
}
|
||||||
|
|
||||||
await apiOverrideWarning();
|
|
||||||
|
|
||||||
await getServerInfo();
|
await getServerInfo();
|
||||||
|
|
||||||
const getCachedInfo = get(cachedInfo);
|
const getCachedInfo = get(cachedInfo);
|
||||||
|
|
|
@ -1,68 +1,9 @@
|
||||||
import { get } from "svelte/store";
|
import { get } from "svelte/store";
|
||||||
|
|
||||||
import env from "$lib/env";
|
|
||||||
import { t } from "$lib/i18n/translations";
|
import { t } from "$lib/i18n/translations";
|
||||||
import settings, { updateSetting } from "$lib/state/settings";
|
import settings, { updateSetting } from "$lib/state/settings";
|
||||||
|
|
||||||
import { createDialog } from "$lib/state/dialogs";
|
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 () => {
|
export const customInstanceWarning = async () => {
|
||||||
if (get(settings).processing.seenCustomWarning) {
|
if (get(settings).processing.seenCustomWarning) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import env from "$lib/env";
|
|
||||||
import settings from "$lib/state/settings";
|
import settings from "$lib/state/settings";
|
||||||
|
|
||||||
import { t } from "$lib/i18n/translations";
|
import { t } from "$lib/i18n/translations";
|
||||||
|
@ -7,26 +6,8 @@
|
||||||
import SettingsToggle from "$components/buttons/SettingsToggle.svelte";
|
import SettingsToggle from "$components/buttons/SettingsToggle.svelte";
|
||||||
import SettingsCategory from "$components/settings/SettingsCategory.svelte";
|
import SettingsCategory from "$components/settings/SettingsCategory.svelte";
|
||||||
import CustomInstanceInput from "$components/settings/CustomInstanceInput.svelte";
|
import CustomInstanceInput from "$components/settings/CustomInstanceInput.svelte";
|
||||||
|
|
||||||
$: overrideDisabled = $settings.processing.enableCustomInstances;
|
|
||||||
</script>
|
</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
|
<SettingsCategory
|
||||||
sectionId="community"
|
sectionId="community"
|
||||||
title={$t("settings.processing.community")}
|
title={$t("settings.processing.community")}
|
||||||
|
|
Loading…
Reference in a new issue