fix store in warning-external-website.ts

This commit is contained in:
Hazelnoot 2025-04-01 11:44:00 -04:00
parent de279a86b2
commit 67cecda7fb

View file

@ -4,13 +4,13 @@
*/ */
import { instance } from '@/instance.js'; import { instance } from '@/instance.js';
import { defaultStore } from '@/store.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import MkUrlWarningDialog from '@/components/MkUrlWarningDialog.vue'; import MkUrlWarningDialog from '@/components/MkUrlWarningDialog.vue';
import { prefer } from '@/preferences';
const isRegExp = /^\/(.+)\/(.*)$/; const isRegExp = /^\/(.+)\/(.*)$/;
function extractHostname(maybeUrl: string): URL | null { function extractHostname(maybeUrl: string): string | null {
try { try {
const url = new URL(maybeUrl); const url = new URL(maybeUrl);
return url.host; return url.host;
@ -36,8 +36,8 @@ export async function warningExternalWebsite(url: string) {
} }
}); });
const isTrustedByUser = defaultStore.reactiveState.trustedDomains.value.includes(hostname); const isTrustedByUser = prefer.r.trustedDomains.value.includes(hostname);
const isDisabledByUser = !defaultStore.reactiveState.warnExternalUrl.value; const isDisabledByUser = !prefer.r.warnExternalUrl.value;
if (!isTrustedByInstance && !isTrustedByUser && !isDisabledByUser) { if (!isTrustedByInstance && !isTrustedByUser && !isDisabledByUser) {
const confirm = await new Promise<{ canceled: boolean }>(resolve => { const confirm = await new Promise<{ canceled: boolean }>(resolve => {