From df0f68251803de1e7f38cde2998a81169dc1df29 Mon Sep 17 00:00:00 2001 From: dakkar Date: Wed, 23 Jul 2025 10:46:01 +0100 Subject: [PATCH 1/3] make `trustedDomains` persist across reloads we can't just write to `prefer.s.*`, we need to `.commit` also, there's no need to use the reactive view (`prefer.r.*`) in non-reactive contexts --- packages/frontend/src/components/MkUrlWarningDialog.vue | 2 +- packages/frontend/src/utility/warning-external-website.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/frontend/src/components/MkUrlWarningDialog.vue b/packages/frontend/src/components/MkUrlWarningDialog.vue index 01ecba1817..8b18942719 100644 --- a/packages/frontend/src/components/MkUrlWarningDialog.vue +++ b/packages/frontend/src/components/MkUrlWarningDialog.vue @@ -64,7 +64,7 @@ function done(canceled: boolean, result?: Result): void { // eslint-disable-line async function ok() { const result = true; if (!prefer.s.trustedDomains.includes(domain.value) && trustThisDomain.value) { - prefer.r.trustedDomains.value = prefer.s.trustedDomains.concat(domain.value); + prefer.commit('trustedDomains', prefer.s.trustedDomains.concat(domain.value)); } done(false, result); } diff --git a/packages/frontend/src/utility/warning-external-website.ts b/packages/frontend/src/utility/warning-external-website.ts index 33cf379b50..28c03c419d 100644 --- a/packages/frontend/src/utility/warning-external-website.ts +++ b/packages/frontend/src/utility/warning-external-website.ts @@ -36,8 +36,8 @@ export async function warningExternalWebsite(url: string) { } }); - const isTrustedByUser = prefer.r.trustedDomains.value.includes(hostname); - const isDisabledByUser = !prefer.r.warnExternalUrl.value; + const isTrustedByUser = prefer.s.trustedDomains.includes(hostname); + const isDisabledByUser = !prefer.s.warnExternalUrl; if (!isTrustedByInstance && !isTrustedByUser && !isDisabledByUser) { const confirm = await new Promise<{ canceled: boolean }>(resolve => { From ab7fd2a7b0dbab5b591bacdbc813a23c56de93c5 Mon Sep 17 00:00:00 2001 From: dakkar Date: Wed, 23 Jul 2025 11:02:37 +0100 Subject: [PATCH 2/3] allow editing `trustedDomains` and sync across devices --- locales/index.d.ts | 8 ++++++++ .../frontend/src/pages/settings/preferences.vue | 15 +++++++++++++++ sharkey-locales/en-US.yml | 2 ++ 3 files changed, 25 insertions(+) diff --git a/locales/index.d.ts b/locales/index.d.ts index 387f92f456..e20b6093e6 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -11976,6 +11976,14 @@ export interface Locale extends ILocale { * Separate with spaces for an AND condition or with line breaks for an OR condition. Using surrounding keywords with slashes will turn them into a regular expression. If you write only the domain name, it will be a backward match. */ "trustedLinkUrlPatternsDescription": string; + /** + * Link to external site warning exclusion list + */ + "trustedDomainsList": string; + /** + * Following links to these domains will not show a warning. Write one domain per line. + */ + "trustedDomainsListDescription": string; /** * Mutuals */ diff --git a/packages/frontend/src/pages/settings/preferences.vue b/packages/frontend/src/pages/settings/preferences.vue index 54b5b6be1c..d21faf61e9 100644 --- a/packages/frontend/src/pages/settings/preferences.vue +++ b/packages/frontend/src/pages/settings/preferences.vue @@ -829,6 +829,15 @@ SPDX-License-Identifier: AGPL-3.0-only + + + + + + + + + @@ -967,6 +976,7 @@ import FormLink from '@/components/form/link.vue'; import MkLink from '@/components/MkLink.vue'; import MkInfo from '@/components/MkInfo.vue'; import MkInput from '@/components/MkInput.vue'; +import MkTextarea from '@/components/MkTextarea.vue'; import { store } from '@/store.js'; import * as os from '@/os.js'; import { misskeyApi } from '@/utility/misskey-api.js'; @@ -1073,6 +1083,11 @@ const lang = prefer.model('lang'); const fontSize = prefer.model('fontSize'); const useSystemFont = prefer.model('useSystemFont'); const cornerRadius = prefer.model('cornerRadius'); +const trustedDomains = prefer.model( + 'trustedDomains', + (domainsList) => domainsList.join('\n'), + (domainsString) => domainsString.split('\n').map( d => d.trim() ).filter( x => x.length > 0), +); watch([ hemisphere, diff --git a/sharkey-locales/en-US.yml b/sharkey-locales/en-US.yml index c49b342f97..1fdcadd087 100644 --- a/sharkey-locales/en-US.yml +++ b/sharkey-locales/en-US.yml @@ -8,6 +8,8 @@ deleteAndEditConfirm: "Are you sure you want to redraft this note? This means yo openRemoteProfile: "Open remote profile" trustedLinkUrlPatterns: "Link to external site warning exclusion list" trustedLinkUrlPatternsDescription: "Separate with spaces for an AND condition or with line breaks for an OR condition. Using surrounding keywords with slashes will turn them into a regular expression. If you write only the domain name, it will be a backward match." +trustedDomainsList: "Link to external site warning exclusion list" +trustedDomainsListDescription: "Following links to these domains will not show a warning. Write one domain per line." mutuals: "Mutuals" isLocked: "Private account" isAdmin: "Administrator" From ed26a7723e7786dfb6bbf7848a2856113ce37124 Mon Sep 17 00:00:00 2001 From: dakkar Date: Wed, 23 Jul 2025 11:02:54 +0100 Subject: [PATCH 3/3] update translation index --- locales/index.d.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/locales/index.d.ts b/locales/index.d.ts index e20b6093e6..85ea73e3d5 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -6005,6 +6005,14 @@ export interface Locale extends ILocale { * New */ "new": string; + /** + * Throw confetti + */ + "confetti": string; + /** + * If enabled, the announcement will display a confetti effect when viewed. + */ + "confettiDescription": string; }; "_initialAccountSetting": { /**