From 710a6ee42307813cd6dc21c04c579356835b5f3d Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Wed, 30 Oct 2024 20:10:18 -0300 Subject: [PATCH] Re-focus stream after theme or language change --- src/js/components/SurahStream/Stream.tsx | 5 ++--- src/js/components/SurahStream/index.tsx | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/js/components/SurahStream/Stream.tsx b/src/js/components/SurahStream/Stream.tsx index ddb476d..dbed6a9 100644 --- a/src/js/components/SurahStream/Stream.tsx +++ b/src/js/components/SurahStream/Stream.tsx @@ -2,7 +2,6 @@ import type { Surah, Ayah, TAyat, TLocale } from "@0x1eef/quran"; import { formatNumber, TFunction } from "~/lib/t"; type Props = { - locale: TLocale; surah: Surah; stream: TAyat; endOfStream: boolean; @@ -11,13 +10,13 @@ type Props = { }; export function Stream({ - locale, surah, stream, endOfStream, isPaused, t, }: Props) { + const { theme, locale } = useContext(SettingsContext); const className = endOfStream || isPaused ? ["scroll-y"] : []; const ulRef = useRef(null); const ul = useMemo(() => { @@ -55,7 +54,7 @@ export function Stream({ el.focus(); el.scrollTop = el.scrollHeight; } - }, [stream.length]); + }, [theme, locale.name, stream.length]); return ul; } diff --git a/src/js/components/SurahStream/index.tsx b/src/js/components/SurahStream/index.tsx index fb368e5..e517c17 100644 --- a/src/js/components/SurahStream/index.tsx +++ b/src/js/components/SurahStream/index.tsx @@ -87,7 +87,6 @@ export function SurahStream({ surahId, localeId, t }: Props) { > {t(locale, "TheNobleQuran")}