From 681cd1c3653ecb321dc619d4820f8805e468f881 Mon Sep 17 00:00:00 2001 From: Egbert Bouman Date: Thu, 12 Sep 2024 16:15:55 +0200 Subject: [PATCH] Make shutdown logs scrollable --- .../ui/src/components/layouts/Header.tsx | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/tribler/ui/src/components/layouts/Header.tsx b/src/tribler/ui/src/components/layouts/Header.tsx index b69dfed99e..d38185dc57 100644 --- a/src/tribler/ui/src/components/layouts/Header.tsx +++ b/src/tribler/ui/src/components/layouts/Header.tsx @@ -9,24 +9,34 @@ import LanguageSelect from "../language-select"; import { triblerService } from "@/services/tribler.service"; import { useInterval } from "@/hooks/useInterval"; import { Dialog, DialogContent, DialogHeader, DialogTitle } from "../ui/dialog"; -import { useEffect, useState } from "react"; +import { useEffect, useRef, useState } from "react"; import toast, { Toaster } from 'react-hot-toast'; import Cookies from "js-cookie"; import { DialogDescription } from "@radix-ui/react-dialog"; import { Ban } from "lucide-react"; import { useTranslation } from "react-i18next"; +import { ScrollArea } from "../ui/scroll-area"; export function Header() { const [online, setOnline] = useState(true); const [shutdownLogs, setShutdownLogs] = useState([]); + const logsEndRef = useRef(null) const [searchParams, setSearchParams] = useSearchParams(); const { t } = useTranslation(); + const scrollToBottom = () => { + logsEndRef.current?.scrollIntoView({ behavior: "smooth" }) + } + + useEffect(() => { + scrollToBottom() + }, [shutdownLogs]); + useEffect(() => { const key = searchParams.get("key"); if (key) { const oldKey = Cookies.get("api_key"); - Cookies.set("api_key", key, { sameSite:'strict' }); + Cookies.set("api_key", key, { sameSite: 'strict' }); searchParams.delete("key"); setSearchParams(searchParams); if (key !== oldKey) { @@ -86,9 +96,12 @@ export function Header() { Tribler may not be running or your browser is missing a cookie.
In latter case please re-open Tribler from the system tray - : - {shutdownLogs.map(log =>

{log}

)} -
+ : + + {shutdownLogs.map(log =>

{log}

)} +
+ + }