From fe4bb4386e0d071ea958dbc70be9e4d58cae81b5 Mon Sep 17 00:00:00 2001 From: Hampus Date: Thu, 15 Oct 2026 00:35:06 +0200 Subject: [PATCH] fix(app): limit /tts playback to the viewed channel (#3484) --- .../src/features/i18n/locales/ar/messages.po | 4 +- .../locales/auto-i18n-reviewed-unchanged.json | 1 + .../src/features/i18n/locales/bg/messages.po | 4 +- .../src/features/i18n/locales/cs/messages.po | 4 +- .../src/features/i18n/locales/da/messages.po | 4 +- .../src/features/i18n/locales/de/messages.po | 4 +- .../src/features/i18n/locales/el/messages.po | 4 +- .../features/i18n/locales/en-GB/messages.po | 4 +- .../features/i18n/locales/en-US/messages.po | 4 +- .../features/i18n/locales/es-419/messages.po | 4 +- .../features/i18n/locales/es-ES/messages.po | 4 +- .../src/features/i18n/locales/fi/messages.po | 4 +- .../src/features/i18n/locales/fr/messages.po | 4 +- .../src/features/i18n/locales/he/messages.po | 4 +- .../src/features/i18n/locales/hi/messages.po | 4 +- .../src/features/i18n/locales/hr/messages.po | 4 +- .../src/features/i18n/locales/hu/messages.po | 4 +- .../src/features/i18n/locales/id/messages.po | 4 +- .../src/features/i18n/locales/it/messages.po | 4 +- .../src/features/i18n/locales/ja/messages.po | 4 +- .../src/features/i18n/locales/ko/messages.po | 4 +- .../src/features/i18n/locales/lt/messages.po | 4 +- .../src/features/i18n/locales/nl/messages.po | 4 +- .../src/features/i18n/locales/no/messages.po | 4 +- .../src/features/i18n/locales/pl/messages.po | 4 +- .../features/i18n/locales/pt-BR/messages.po | 4 +- .../src/features/i18n/locales/ro/messages.po | 4 +- .../src/features/i18n/locales/ru/messages.po | 4 +- .../features/i18n/locales/sv-SE/messages.po | 4 +- .../src/features/i18n/locales/th/messages.po | 4 +- .../src/features/i18n/locales/tr/messages.po | 4 +- .../src/features/i18n/locales/uk/messages.po | 4 +- .../src/features/i18n/locales/vi/messages.po | 4 +- .../features/i18n/locales/zh-CN/messages.po | 4 +- .../features/i18n/locales/zh-TW/messages.po | 4 +- .../src/features/ui/state/Notification.ts | 2 +- .../tabs/notifications_tab/TextToSpeech.tsx | 6 +- .../voice/utils/VoiceTtsUtils.test.ts | 217 ++++++++++++++++++ .../features/voice/utils/VoiceTtsUtils.tsx | 21 +- 39 files changed, 299 insertions(+), 84 deletions(-) create mode 100644 fluxer_app/src/features/voice/utils/VoiceTtsUtils.test.ts diff --git a/fluxer_app/src/features/i18n/locales/ar/messages.po b/fluxer_app/src/features/i18n/locales/ar/messages.po index 9212c0035..9b920256f 100644 --- a/fluxer_app/src/features/i18n/locales/ar/messages.po +++ b/fluxer_app/src/features/i18n/locales/ar/messages.po @@ -26957,8 +26957,8 @@ msgstr "أعد التحميل لتطبيق تغيير المحرك" #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "يبقى صامتًا ما لم يستخدم أحدهم الأمر /tts يدويًا." +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "ابقَ صامتًا إلا إذا قام شخص ما بتشغيل الأمر `/tts` في القناة التي تشاهدها." #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/auto-i18n-reviewed-unchanged.json b/fluxer_app/src/features/i18n/locales/auto-i18n-reviewed-unchanged.json index 5ebf59a55..0734c20eb 100644 --- a/fluxer_app/src/features/i18n/locales/auto-i18n-reviewed-unchanged.json +++ b/fluxer_app/src/features/i18n/locales/auto-i18n-reviewed-unchanged.json @@ -1317,6 +1317,7 @@ "Register an account", "Registration", "Relaunch to apply", + "Remain silent unless someone runs /tts in the channel you're viewing.", "Remove from recent instances", "Remove from thread", "Remove members from the community. They can rejoin with a new invite.", diff --git a/fluxer_app/src/features/i18n/locales/bg/messages.po b/fluxer_app/src/features/i18n/locales/bg/messages.po index f85b424e1..16f1086c9 100644 --- a/fluxer_app/src/features/i18n/locales/bg/messages.po +++ b/fluxer_app/src/features/i18n/locales/bg/messages.po @@ -26957,8 +26957,8 @@ msgstr "Презареди, за да приложиш смяната на мо #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "Не чете нищо, освен ако някой не пусне /tts ръчно." +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "Оставай тих, освен ако някой не въведе `/tts` в канала, който разглеждаш." #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/cs/messages.po b/fluxer_app/src/features/i18n/locales/cs/messages.po index 91d90942f..c08a6e797 100644 --- a/fluxer_app/src/features/i18n/locales/cs/messages.po +++ b/fluxer_app/src/features/i18n/locales/cs/messages.po @@ -26957,8 +26957,8 @@ msgstr "Znovu načíst pro použití změny nástroje" #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "Zůstat zticha, pokud někdo nespustí /tts ručně." +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "Zůstaň potichu, pokud někdo v kanálu, který sleduješ, nespustí příkaz /tts." #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/da/messages.po b/fluxer_app/src/features/i18n/locales/da/messages.po index 150fe3a54..67c9865d8 100644 --- a/fluxer_app/src/features/i18n/locales/da/messages.po +++ b/fluxer_app/src/features/i18n/locales/da/messages.po @@ -26957,8 +26957,8 @@ msgstr "Genindlæs for at anvende motorændring" #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "Forbliv lydløs, medmindre nogen manuelt kører /tts." +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "Forbliv tavs, medmindre nogen skriver /tts i den kanal, du ser." #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/de/messages.po b/fluxer_app/src/features/i18n/locales/de/messages.po index 47a1084de..091d95e6d 100644 --- a/fluxer_app/src/features/i18n/locales/de/messages.po +++ b/fluxer_app/src/features/i18n/locales/de/messages.po @@ -26957,8 +26957,8 @@ msgstr "Neu laden, um Engine-Änderung zu übernehmen" #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "Bleibe stumm, es sei denn, jemand führt /tts manuell aus." +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "Bleib stumm, es sei denn, jemand führt /tts in dem Kanal aus, den du gerade ansiehst." #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/el/messages.po b/fluxer_app/src/features/i18n/locales/el/messages.po index 4f62f38dd..22939a46f 100644 --- a/fluxer_app/src/features/i18n/locales/el/messages.po +++ b/fluxer_app/src/features/i18n/locales/el/messages.po @@ -26957,8 +26957,8 @@ msgstr "Επανεκκίνηση για εφαρμογή της αλλαγής #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "Να παραμένει σιωπηλό, εκτός αν κάποιος εκτελέσει το /tts χειροκίνητα." +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "Παραμείνετε σιωπηλοί, εκτός αν κάποιος πληκτρολογήσει /tts στο κανάλι που βλέπετε." #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/en-GB/messages.po b/fluxer_app/src/features/i18n/locales/en-GB/messages.po index ee7b5bfa9..a96e72089 100644 --- a/fluxer_app/src/features/i18n/locales/en-GB/messages.po +++ b/fluxer_app/src/features/i18n/locales/en-GB/messages.po @@ -26957,8 +26957,8 @@ msgstr "Reload to apply engine change" #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "Remain silent unless someone runs /tts manually." +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "Remain silent unless someone runs /tts in the channel you're viewing." #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/en-US/messages.po b/fluxer_app/src/features/i18n/locales/en-US/messages.po index 80e4a0521..79d6f6135 100644 --- a/fluxer_app/src/features/i18n/locales/en-US/messages.po +++ b/fluxer_app/src/features/i18n/locales/en-US/messages.po @@ -26957,8 +26957,8 @@ msgstr "Reload to apply engine change" #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "Remain silent unless someone runs /tts manually." +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "Remain silent unless someone runs /tts in the channel you're viewing." #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/es-419/messages.po b/fluxer_app/src/features/i18n/locales/es-419/messages.po index 27fc6db4f..daf3459f4 100644 --- a/fluxer_app/src/features/i18n/locales/es-419/messages.po +++ b/fluxer_app/src/features/i18n/locales/es-419/messages.po @@ -26957,8 +26957,8 @@ msgstr "Recargar para aplicar el cambio de motor" #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "Permanecer en silencio a menos que alguien ejecute /tts manualmente." +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "Permanece en silencio a menos que alguien escriba /tts en el canal que estás viendo." #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/es-ES/messages.po b/fluxer_app/src/features/i18n/locales/es-ES/messages.po index 4308a4f2c..dc6c77e43 100644 --- a/fluxer_app/src/features/i18n/locales/es-ES/messages.po +++ b/fluxer_app/src/features/i18n/locales/es-ES/messages.po @@ -26957,8 +26957,8 @@ msgstr "Recargar para aplicar el cambio de motor" #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "Permanecer en silencio a menos que alguien ejecute /tts manualmente." +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "Permanece en silencio a menos que alguien ejecute /tts en el canal que estás viendo." #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/fi/messages.po b/fluxer_app/src/features/i18n/locales/fi/messages.po index 311d08ed8..17ea21e16 100644 --- a/fluxer_app/src/features/i18n/locales/fi/messages.po +++ b/fluxer_app/src/features/i18n/locales/fi/messages.po @@ -26957,8 +26957,8 @@ msgstr "Lataa uudelleen, jotta moottorin vaihdos tulee voimaan." #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "Pysyy hiljaa, ellei joku käytä /tts-komentoa manuaalisesti." +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "Pysy hiljaa, ellei joku suorita komentoa /tts katsomassasi kanavassa." #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/fr/messages.po b/fluxer_app/src/features/i18n/locales/fr/messages.po index b58bf018b..e6ba4645a 100644 --- a/fluxer_app/src/features/i18n/locales/fr/messages.po +++ b/fluxer_app/src/features/i18n/locales/fr/messages.po @@ -26957,8 +26957,8 @@ msgstr "Recharger pour appliquer le changement de moteur" #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "Rester silencieux, sauf si quelqu'un lance /tts manuellement." +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "Restez silencieux, sauf si quelqu'un tape /tts dans le canal que vous consultez." #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/he/messages.po b/fluxer_app/src/features/i18n/locales/he/messages.po index 67b1b81ce..1b3177ecb 100644 --- a/fluxer_app/src/features/i18n/locales/he/messages.po +++ b/fluxer_app/src/features/i18n/locales/he/messages.po @@ -26957,8 +26957,8 @@ msgstr "יש לטעון מחדש כדי להחיל את שינוי המנוע" #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "לא מקריא דבר אלא אם מישהו מפעיל /tts באופן ידני." +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "הישאר שקט אלא אם מישהו מריץ /tts בערוץ שאתה צופה בו." #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/hi/messages.po b/fluxer_app/src/features/i18n/locales/hi/messages.po index 704f51afb..43d3233fe 100644 --- a/fluxer_app/src/features/i18n/locales/hi/messages.po +++ b/fluxer_app/src/features/i18n/locales/hi/messages.po @@ -26957,8 +26957,8 @@ msgstr "इंजन में बदलाव लागू करने के #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "जब तक कोई खुद /tts न चलाए, तब तक कुछ नहीं सुनाया जाता।" +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "जब तक कोई उस चैनल में /tts न चलाए जिसे आप देख रहे हैं, तब तक कुछ नहीं सुनाया जाता।" #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/hr/messages.po b/fluxer_app/src/features/i18n/locales/hr/messages.po index a15126656..8d62ef169 100644 --- a/fluxer_app/src/features/i18n/locales/hr/messages.po +++ b/fluxer_app/src/features/i18n/locales/hr/messages.po @@ -26957,8 +26957,8 @@ msgstr "Ponovo učitaj za primjenu promjene mehanizma" #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "Ne čita ništa naglas osim ako netko ručno ne pokrene /tts." +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "Ostani tih, osim ako netko ne pokrene /tts u kanalu koji gledaš." #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/hu/messages.po b/fluxer_app/src/features/i18n/locales/hu/messages.po index a3ee27772..ded408a5c 100644 --- a/fluxer_app/src/features/i18n/locales/hu/messages.po +++ b/fluxer_app/src/features/i18n/locales/hu/messages.po @@ -26957,8 +26957,8 @@ msgstr "Újratöltés a motorváltás érvényesítéséhez" #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "Maradjon csendben, hacsak valaki manuálisan nem futtatja a /tts parancsot." +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "Maradj csendben, hacsak valaki be nem írja a `/tts` parancsot a megtekintett csatornában." #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/id/messages.po b/fluxer_app/src/features/i18n/locales/id/messages.po index 2cdd948a1..30decb357 100644 --- a/fluxer_app/src/features/i18n/locales/id/messages.po +++ b/fluxer_app/src/features/i18n/locales/id/messages.po @@ -26957,8 +26957,8 @@ msgstr "Muat ulang untuk menerapkan perubahan mesin" #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "Tetap diam kecuali seseorang menjalankan /tts secara manual." +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "Tetap senyap kecuali seseorang mengetik /tts di kanal yang sedang Anda lihat." #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/it/messages.po b/fluxer_app/src/features/i18n/locales/it/messages.po index 30ef0f60a..cfdcd1024 100644 --- a/fluxer_app/src/features/i18n/locales/it/messages.po +++ b/fluxer_app/src/features/i18n/locales/it/messages.po @@ -26957,8 +26957,8 @@ msgstr "Ricarica per applicare la modifica al motore" #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "Rimani in silenzio a meno che qualcuno non esegua /tts manualmente." +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "Rimani in silenzio a meno che qualcuno non esegua /tts nel canale che stai visualizzando." #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/ja/messages.po b/fluxer_app/src/features/i18n/locales/ja/messages.po index 9f6868a30..7e029feff 100644 --- a/fluxer_app/src/features/i18n/locales/ja/messages.po +++ b/fluxer_app/src/features/i18n/locales/ja/messages.po @@ -26957,8 +26957,8 @@ msgstr "エンジン変更を適用するには再読み込みしてください #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "誰かが手動で /tts を実行しない限り、読み上げません。" +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "表示中のチャンネルで誰かが `/tts` を実行した場合にのみ、発言します。" #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/ko/messages.po b/fluxer_app/src/features/i18n/locales/ko/messages.po index 7166c3893..19d61c2ed 100644 --- a/fluxer_app/src/features/i18n/locales/ko/messages.po +++ b/fluxer_app/src/features/i18n/locales/ko/messages.po @@ -26957,8 +26957,8 @@ msgstr "엔진 변경 사항을 적용하려면 다시 로드하세요" #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "누군가 /tts를 직접 실행하지 않는 한 무음으로 유지됩니다." +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "보고 있는 채널에서 누군가 /tts를 실행하지 않는 한 무음으로 유지됩니다." #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/lt/messages.po b/fluxer_app/src/features/i18n/locales/lt/messages.po index 22e8c3a4f..9d4c6eede 100644 --- a/fluxer_app/src/features/i18n/locales/lt/messages.po +++ b/fluxer_app/src/features/i18n/locales/lt/messages.po @@ -26958,8 +26958,8 @@ msgstr "Įkelti iš naujo, kad būtų pritaikytas variklio pakeitimas" #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "Tylėti, nebent kas nors rankiniu būdu paleidžia /tts." +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "Pasilikite tyliai, nebent kas nors kanale, kurį žiūrite, parašo /tts." #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/nl/messages.po b/fluxer_app/src/features/i18n/locales/nl/messages.po index 55d40f084..66ed0b0f4 100644 --- a/fluxer_app/src/features/i18n/locales/nl/messages.po +++ b/fluxer_app/src/features/i18n/locales/nl/messages.po @@ -26957,8 +26957,8 @@ msgstr "Opnieuw laden om de spellingscontrolemethode te wijzigen" #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "Blijf stil, tenzij iemand handmatig /tts uitvoert." +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "Blijf stil, tenzij iemand /tts uitvoert in het kanaal dat je bekijkt." #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/no/messages.po b/fluxer_app/src/features/i18n/locales/no/messages.po index 0e8bc6e58..9ecd9a5b2 100644 --- a/fluxer_app/src/features/i18n/locales/no/messages.po +++ b/fluxer_app/src/features/i18n/locales/no/messages.po @@ -26957,8 +26957,8 @@ msgstr "Last inn på nytt for å ta den nye stavekontrollmotoren i bruk" #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "Forbli stille med mindre noen kjører /tts manuelt." +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "Vær stille med mindre noen skriver /tts i kanalen du ser på." #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/pl/messages.po b/fluxer_app/src/features/i18n/locales/pl/messages.po index d0b549c6f..c22fdca0e 100644 --- a/fluxer_app/src/features/i18n/locales/pl/messages.po +++ b/fluxer_app/src/features/i18n/locales/pl/messages.po @@ -26957,8 +26957,8 @@ msgstr "Załaduj ponownie, aby zastosować zmianę silnika" #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "Pozostań w trybie cichym, chyba że ktoś ręcznie uruchomi /tts." +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "Pozostawaj cicho, chyba że ktoś wpisze `/tts` na kanale, który przeglądasz." #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/pt-BR/messages.po b/fluxer_app/src/features/i18n/locales/pt-BR/messages.po index d7d17a529..a144ea0cf 100644 --- a/fluxer_app/src/features/i18n/locales/pt-BR/messages.po +++ b/fluxer_app/src/features/i18n/locales/pt-BR/messages.po @@ -26957,8 +26957,8 @@ msgstr "Recarregar para aplicar a mudança no mecanismo" #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "Permanecer em silêncio, a menos que alguém execute /tts manualmente." +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "Fique em silêncio, a menos que alguém digite /tts no canal que você está vendo." #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/ro/messages.po b/fluxer_app/src/features/i18n/locales/ro/messages.po index 18dd335b3..88d191cae 100644 --- a/fluxer_app/src/features/i18n/locales/ro/messages.po +++ b/fluxer_app/src/features/i18n/locales/ro/messages.po @@ -26957,8 +26957,8 @@ msgstr "Reîncarcă pentru a aplica modificarea motorului" #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "Nu se aude nimic decât dacă cineva rulează manual /tts." +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "Rămâi tăcut, cu excepția cazului în care cineva rulează /tts în canalul pe care îl vizualizezi." #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/ru/messages.po b/fluxer_app/src/features/i18n/locales/ru/messages.po index e355e82e3..3b7b207a9 100644 --- a/fluxer_app/src/features/i18n/locales/ru/messages.po +++ b/fluxer_app/src/features/i18n/locales/ru/messages.po @@ -26957,8 +26957,8 @@ msgstr "Перезагрузите, чтобы применить смену д #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "Молчать, пока кто-нибудь не запустит /tts вручную." +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "Оставайся в тишине, если кто-то не введёт команду /tts в канале, который ты просматриваешь." #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/sv-SE/messages.po b/fluxer_app/src/features/i18n/locales/sv-SE/messages.po index 74a647011..a86388a28 100644 --- a/fluxer_app/src/features/i18n/locales/sv-SE/messages.po +++ b/fluxer_app/src/features/i18n/locales/sv-SE/messages.po @@ -26957,8 +26957,8 @@ msgstr "Ladda om för att tillämpa motorändring" #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "Förbli tyst om inte någon kör /tts manuellt." +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "Var tyst om ingen skriver /tts i kanalen du tittar på." #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/th/messages.po b/fluxer_app/src/features/i18n/locales/th/messages.po index 227700a21..b9be7efca 100644 --- a/fluxer_app/src/features/i18n/locales/th/messages.po +++ b/fluxer_app/src/features/i18n/locales/th/messages.po @@ -26957,8 +26957,8 @@ msgstr "โหลดใหม่เพื่อใช้เครื่องม #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "จะไม่มีเสียงพูดจนกว่าจะมีคนใช้คำสั่ง /tts ด้วยตัวเอง" +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "เงียบไว้ เว้นแต่จะมีคนพิมพ์ /tts ในแชทที่คุณกำลังดู" #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/tr/messages.po b/fluxer_app/src/features/i18n/locales/tr/messages.po index 66a44f3ce..1161f3e8e 100644 --- a/fluxer_app/src/features/i18n/locales/tr/messages.po +++ b/fluxer_app/src/features/i18n/locales/tr/messages.po @@ -26957,8 +26957,8 @@ msgstr "Motor değişikliğini uygulamak için yeniden yükle" #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "Birisi /tts komutunu manuel olarak çalıştırmadıkça sessiz kalır." +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "Görüntülediğin kanalda biri /tts komutunu çalıştırmadığı sürece sessiz kal." #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/uk/messages.po b/fluxer_app/src/features/i18n/locales/uk/messages.po index 0f7bf5d3f..728d7b301 100644 --- a/fluxer_app/src/features/i18n/locales/uk/messages.po +++ b/fluxer_app/src/features/i18n/locales/uk/messages.po @@ -26957,8 +26957,8 @@ msgstr "Перезавантажте, щоб застосувати зміну #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "Нічого не озвучує, доки хтось не запустить /tts вручну." +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "Залишайтеся мовчазними, доки хтось не введе команду /tts у каналі, який ви переглядаєте." #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/vi/messages.po b/fluxer_app/src/features/i18n/locales/vi/messages.po index ccadde0d2..548b5ffbb 100644 --- a/fluxer_app/src/features/i18n/locales/vi/messages.po +++ b/fluxer_app/src/features/i18n/locales/vi/messages.po @@ -26957,8 +26957,8 @@ msgstr "Tải lại để áp dụng thay đổi công cụ" #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "Giữ im lặng trừ khi có người chạy lệnh /tts thủ công." +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "Giữ im lặng trừ khi ai đó nhập `/tts` trong kênh bạn đang xem." #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/zh-CN/messages.po b/fluxer_app/src/features/i18n/locales/zh-CN/messages.po index f3b7e666d..ca7b08272 100644 --- a/fluxer_app/src/features/i18n/locales/zh-CN/messages.po +++ b/fluxer_app/src/features/i18n/locales/zh-CN/messages.po @@ -26957,8 +26957,8 @@ msgstr "重新加载以应用引擎更改" #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "除非有人手动运行 /tts,否则保持静默。" +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "除非有人在你正在查看的频道中运行 /tts,否则保持静默。" #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/i18n/locales/zh-TW/messages.po b/fluxer_app/src/features/i18n/locales/zh-TW/messages.po index 876c89b42..db9097531 100644 --- a/fluxer_app/src/features/i18n/locales/zh-TW/messages.po +++ b/fluxer_app/src/features/i18n/locales/zh-TW/messages.po @@ -26957,8 +26957,8 @@ msgstr "重新載入以套用引擎變更" #. Description text in the text to speech. #: src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx -msgid "Remain silent unless someone runs /tts manually." -msgstr "除非有人手動執行 /tts,否則保持靜音。" +msgid "Remain silent unless someone runs /tts in the channel you're viewing." +msgstr "除非您所在的頻道有人輸入 /tts,否則保持靜默。" #. Settings search entry label. Names the settings search entry in the settings UI. #: src/features/user/components/settings_utils/search_index/DesktopSettingsIndex.ts diff --git a/fluxer_app/src/features/ui/state/Notification.ts b/fluxer_app/src/features/ui/state/Notification.ts index aafb63f0b..44db15ad5 100644 --- a/fluxer_app/src/features/ui/state/Notification.ts +++ b/fluxer_app/src/features/ui/state/Notification.ts @@ -252,7 +252,7 @@ class NotificationState { return Navigation.channelId ?? SelectedChannel.currentChannelId; } - private isViewingChannel(channelId: string): boolean { + isViewingChannel(channelId: string): boolean { return this.getVisibleChannelId() === channelId || Navigation.threadId === channelId; } diff --git a/fluxer_app/src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx b/fluxer_app/src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx index ac8dd2c22..6e76eb05f 100644 --- a/fluxer_app/src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx +++ b/fluxer_app/src/features/user/components/modals/tabs/notifications_tab/TextToSpeech.tsx @@ -34,8 +34,8 @@ const NEVER_AUTOMATICALLY_DESCRIPTOR = msg({ message: 'Never automatically', comment: 'Short label in the text to speech. Keep it concise.', }); -const REMAIN_SILENT_UNLESS_SOMEONE_RUNS_TTS_MANUALLY_DESCRIPTOR = msg({ - message: 'Remain silent unless someone runs /tts manually.', +const REMAIN_SILENT_UNLESS_SOMEONE_RUNS_TTS_IN_VIEWED_CHANNEL_DESCRIPTOR = msg({ + message: "Remain silent unless someone runs /tts in the channel you're viewing.", comment: 'Description text in the text to speech.', }); const ENABLE_TTS_SPEECH_PLAYBACK_DESCRIPTOR = msg({ @@ -81,7 +81,7 @@ export const TextToSpeech = observer(() => { { value: TTSNotificationMode.NEVER, name: i18n._(NEVER_AUTOMATICALLY_DESCRIPTOR), - desc: i18n._(REMAIN_SILENT_UNLESS_SOMEONE_RUNS_TTS_MANUALLY_DESCRIPTOR), + desc: i18n._(REMAIN_SILENT_UNLESS_SOMEONE_RUNS_TTS_IN_VIEWED_CHANNEL_DESCRIPTOR), }, ]; const handleTtsNotificationChange = useCallback((value: TTSNotificationMode) => { diff --git a/fluxer_app/src/features/voice/utils/VoiceTtsUtils.test.ts b/fluxer_app/src/features/voice/utils/VoiceTtsUtils.test.ts new file mode 100644 index 000000000..370bd0c8c --- /dev/null +++ b/fluxer_app/src/features/voice/utils/VoiceTtsUtils.test.ts @@ -0,0 +1,217 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later +// @vitest-environment happy-dom + +import {MessageTypes} from '@fluxer/constants/src/ChannelConstants'; +import type {Message} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; +import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest'; + +const ME = '100'; +const OTHER = '200'; +const SELECTED_CHANNEL = '1000'; +const THREAD_CHANNEL = '2000'; +const OTHER_CHANNEL = '3000'; + +const state = { + enableTTSCommand: true, + selfDeaf: false, + navigationChannelId: null as string | null, + selectedChannelId: SELECTED_CHANNEL as string | null, + threadId: null as string | null, + mutedChannelIds: new Set(), +}; + +const speak = vi.fn(); + +vi.mock('@lingui/core/macro', () => ({ + msg: (descriptor: unknown) => descriptor, + t: (descriptor: unknown) => descriptor, +})); + +vi.mock('@lingui/react/macro', () => ({ + Trans: () => null, + useLingui: () => ({i18n: {_: (descriptor: {message?: string}) => descriptor.message ?? ''}}), +})); + +vi.mock('@app/features/voice/utils/TtsSpeechUtils', () => ({ + nativeApiPresent: () => true, + nativeHasVoices: () => true, + resumeNative: vi.fn(), + cancel: vi.fn(), + speak: (utterance: {text: string}) => speak(utterance.text), + createUtterances: (text: string) => [{text}], + getVoices: () => [], + selectPreferredVoice: () => null, +})); + +vi.mock('@app/features/ui/utils/NativeUtils', async (importOriginal) => ({ + ...(await importOriginal()), + getNativePlatformSync: () => 'web', +})); + +vi.mock('@app/features/navigation/state/Navigation', () => ({ + default: { + get channelId() { + return state.navigationChannelId; + }, + get threadId() { + return state.threadId; + }, + }, +})); + +vi.mock('@app/features/accessibility/state/Accessibility', () => ({ + default: { + get enableTTSCommand() { + return state.enableTTSCommand; + }, + ttsRate: 1, + }, +})); + +vi.mock('@app/features/auth/state/Authentication', () => ({default: {currentUserId: ME}})); + +vi.mock('@app/features/navigation/state/SelectedChannel', () => ({ + default: { + get currentChannelId() { + return state.selectedChannelId; + }, + }, +})); + +vi.mock('@app/features/relationship/state/Relationships', () => ({default: {isBlocked: () => false}})); + +vi.mock('@app/features/channel/state/Channels', () => ({ + default: {getChannel: (id: string) => ({id, guildId: '1'})}, +})); + +vi.mock('@app/features/user/state/UserGuildSettings', () => ({ + default: { + isGuildOrChannelMuted: (_guildId: string | null, channelId: string) => state.mutedChannelIds.has(channelId), + isParentCategoryMuted: () => false, + }, +})); + +vi.mock('@app/features/user/state/UserSettings', () => ({default: {locale: 'en-US'}})); +vi.mock('@app/features/user/state/Users', () => ({default: {getUser: (id: string) => ({id})}})); +vi.mock('@app/features/user/utils/NicknameUtils', () => ({getNickname: (user: {id: string}) => user.id})); +vi.mock('@app/features/voice/utils/TtsTextFormatter', () => ({formatMessageForTts: (content: string) => content})); +vi.mock('@app/features/messaging/state/MessageReferences', () => ({ + default: {getMessageReference: () => ({state: 0})}, + MessageReferenceState: {LOADED: 1}, +})); +vi.mock('@app/features/messaging/utils/SystemMessageUtils', () => ({ + SystemMessageUtils: {stringify: () => 'system'}, +})); + +Object.defineProperty(window, 'speechSynthesis', { + configurable: true, + value: {addEventListener: vi.fn(), removeEventListener: vi.fn()}, +}); + +const {default: LocalVoiceState} = await import('@app/features/voice/state/LocalVoiceState'); +vi.spyOn(LocalVoiceState, 'getSelfDeaf').mockImplementation(() => state.selfDeaf); +const {default: Notification, TTSNotificationMode} = await import('@app/features/ui/state/Notification'); +const {default: TtsUtils} = await import('@app/features/voice/utils/VoiceTtsUtils'); + +let nextId = 1; + +function message(overrides: {channelId?: string; authorId?: string; tts?: boolean; type?: number}): Message { + return { + id: String(nextId++), + channel_id: overrides.channelId ?? SELECTED_CHANNEL, + author: {id: overrides.authorId ?? OTHER}, + type: overrides.type ?? MessageTypes.DEFAULT, + tts: overrides.tts ?? false, + content: 'hello', + } as unknown as Message; +} + +function spoken(input: Parameters[0]): boolean { + speak.mockClear(); + TtsUtils.handleIncomingTtsMessage(message(input)); + return speak.mock.calls.length > 0; +} + +describe('incoming message text-to-speech gate', () => { + beforeEach(() => { + Notification.setTTSNotificationMode(TTSNotificationMode.NEVER); + state.navigationChannelId = null; + state.enableTTSCommand = true; + state.selfDeaf = false; + state.selectedChannelId = SELECTED_CHANNEL; + state.threadId = null; + state.mutedChannelIds = new Set(); + }); + + afterEach(() => { + TtsUtils.dispose(); + }); + + it('keeps /tts from a channel you are not viewing silent when narration is off', () => { + expect(spoken({channelId: OTHER_CHANNEL, tts: true})).toBe(false); + }); + + it('speaks /tts in the selected channel when narration is off', () => { + expect(spoken({tts: true})).toBe(true); + }); + + it('speaks /tts in the thread open in the side panel when narration is off', () => { + state.threadId = THREAD_CHANNEL; + expect(spoken({channelId: THREAD_CHANNEL, tts: true})).toBe(true); + }); + + it('follows the routed channel over a stale selected channel', () => { + state.navigationChannelId = OTHER_CHANNEL; + expect(spoken({channelId: OTHER_CHANNEL, tts: true})).toBe(true); + expect(spoken({tts: true})).toBe(false); + }); + + it('speaks your own /tts in the selected channel', () => { + expect(spoken({authorId: ME, tts: true})).toBe(true); + }); + + it('keeps /tts silent when /tts playback is disabled', () => { + state.enableTTSCommand = false; + expect(spoken({tts: true})).toBe(false); + }); + + it('does not narrate your own plain messages', () => { + Notification.setTTSNotificationMode(TTSNotificationMode.FOR_ALL_CHANNELS); + expect(spoken({authorId: ME})).toBe(false); + }); + + it('does not narrate your own system messages', () => { + Notification.setTTSNotificationMode(TTSNotificationMode.FOR_ALL_CHANNELS); + expect(spoken({authorId: ME, type: MessageTypes.CHANNEL_PINNED_MESSAGE})).toBe(false); + }); + + it('narrates other channels only in every-channel mode', () => { + Notification.setTTSNotificationMode(TTSNotificationMode.FOR_ALL_CHANNELS); + expect(spoken({channelId: OTHER_CHANNEL})).toBe(true); + Notification.setTTSNotificationMode(TTSNotificationMode.FOR_CURRENT_CHANNEL); + expect(spoken({channelId: OTHER_CHANNEL})).toBe(false); + }); + + it('narrates the side-panel thread in current-channel mode', () => { + Notification.setTTSNotificationMode(TTSNotificationMode.FOR_CURRENT_CHANNEL); + state.threadId = THREAD_CHANNEL; + expect(spoken({channelId: THREAD_CHANNEL})).toBe(true); + }); + + it('stays silent in every mode while self-deafened', () => { + state.selfDeaf = true; + for (const mode of [ + TTSNotificationMode.NEVER, + TTSNotificationMode.FOR_CURRENT_CHANNEL, + TTSNotificationMode.FOR_ALL_CHANNELS, + ]) { + Notification.setTTSNotificationMode(mode); + expect(spoken({tts: true})).toBe(false); + } + }); + + it('stays silent in a muted channel', () => { + state.mutedChannelIds.add(SELECTED_CHANNEL); + expect(spoken({tts: true})).toBe(false); + }); +}); diff --git a/fluxer_app/src/features/voice/utils/VoiceTtsUtils.tsx b/fluxer_app/src/features/voice/utils/VoiceTtsUtils.tsx index 450470087..b388afde0 100644 --- a/fluxer_app/src/features/voice/utils/VoiceTtsUtils.tsx +++ b/fluxer_app/src/features/voice/utils/VoiceTtsUtils.tsx @@ -13,6 +13,7 @@ import UserGuildSettings from '@app/features/user/state/UserGuildSettings'; import UserSettings from '@app/features/user/state/UserSettings'; import Users from '@app/features/user/state/Users'; import * as NicknameUtils from '@app/features/user/utils/NicknameUtils'; +import LocalVoiceState from '@app/features/voice/state/LocalVoiceState'; import * as TtsSpeechUtils from '@app/features/voice/utils/TtsSpeechUtils'; import {formatMessageForTts} from '@app/features/voice/utils/TtsTextFormatter'; import {MessageTypes} from '@fluxer/constants/src/ChannelConstants'; @@ -365,22 +366,18 @@ function describeNonTextContent(message: Message, authorName: string, localI18n: } function shouldSpeakMessage(message: Message): boolean { - const mode = Notification.ttsNotificationMode; - const isExplicitTts = message.tts === true; - const isSelf = message.author.id === Authentication.currentUserId; - const isSystemMessage = !isUserMessageType(message.type); - if (isSelf && !isSystemMessage) { + if (LocalVoiceState.getSelfDeaf()) { return false; } - if (mode === TTSNotificationMode.NEVER) { - return isExplicitTts && Accessibility.enableTTSCommand; + const viewing = Notification.isViewingChannel(message.channel_id); + if (Accessibility.enableTTSCommand && message.tts === true && viewing) { + return true; } - if (mode === TTSNotificationMode.FOR_CURRENT_CHANNEL) { - if (message.channel_id !== SelectedChannel.currentChannelId) { - return false; - } + if (message.author.id === Authentication.currentUserId) { + return false; } - return true; + const mode = Notification.ttsNotificationMode; + return mode === TTSNotificationMode.FOR_ALL_CHANNELS || (mode === TTSNotificationMode.FOR_CURRENT_CHANNEL && viewing); } function handleIncomingTtsMessage(message: Message): void {