From 28d479ceb3d09464d28986f0ab7f9c2a6dbe0b6d Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 5 Sep 2025 20:51:08 +0200 Subject: [PATCH] =?UTF-8?q?[Glitch]=20Change=20=E2=80=9CPosting=20defaults?= =?UTF-8?q?=E2=80=9D=20settings=20page=20to=20enforce=20`nobody`=20quote?= =?UTF-8?q?=20policy=20for=20`private`=20default=20visibility?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Port 9463a31107beccf3adc3e2f4079fbfb123b7bebc to glitch-soc Signed-off-by: Claire --- .../flavours/glitch/entrypoints/public.tsx | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/app/javascript/flavours/glitch/entrypoints/public.tsx b/app/javascript/flavours/glitch/entrypoints/public.tsx index 90c4ef8c87..75c06e7cd0 100644 --- a/app/javascript/flavours/glitch/entrypoints/public.tsx +++ b/app/javascript/flavours/glitch/entrypoints/public.tsx @@ -145,6 +145,10 @@ function loaded() { ); }); + updateDefaultQuotePrivacyFromPrivacy( + document.querySelector('#user_settings_attributes_default_privacy'), + ); + const reactComponents = document.querySelectorAll('[data-component]'); if (reactComponents.length > 0) { @@ -364,6 +368,34 @@ Rails.delegate( }, ); +const updateDefaultQuotePrivacyFromPrivacy = ( + privacySelect: EventTarget | null, +) => { + if (!(privacySelect instanceof HTMLSelectElement) || !privacySelect.form) + return; + + const select = privacySelect.form.querySelector( + 'select#user_settings_attributes_default_quote_policy', + ); + if (!select) return; + + if (privacySelect.value === 'private') { + select.value = 'nobody'; + setInputDisabled(select, true); + } else { + setInputDisabled(select, false); + } +}; + +Rails.delegate( + document, + '#user_settings_attributes_default_privacy', + 'change', + ({ target }) => { + updateDefaultQuotePrivacyFromPrivacy(target); + }, +); + // Empty the honeypot fields in JS in case something like an extension // automatically filled them. Rails.delegate(document, '#registration_new_user,#new_user', 'submit', () => {