Re-focus stream after theme or language change

This commit is contained in:
0x1eef 2024-10-30 20:10:18 -03:00
parent 590ddf13e2
commit 710a6ee423
2 changed files with 2 additions and 4 deletions

View file

@ -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<HTMLUListElement>(null);
const ul = useMemo<JSX.Element>(() => {
@ -55,7 +54,7 @@ export function Stream({
el.focus();
el.scrollTop = el.scrollHeight;
}
}, [stream.length]);
}, [theme, locale.name, stream.length]);
return ul;
}

View file

@ -87,7 +87,6 @@ export function SurahStream({ surahId, localeId, t }: Props) {
>
<Head>{t(locale, "TheNobleQuran")}</Head>
<Stream
locale={locale}
surah={surah}
stream={stream}
endOfStream={endOfStream}