Skip to content

Commit

Permalink
Added a new version notification on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
qstokkink committed Sep 4, 2024
1 parent 4f6aaf6 commit 67d140d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
18 changes: 17 additions & 1 deletion src/tribler/ui/src/components/layouts/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ 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 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";

export function Header() {
const [online, setOnline] = useState<boolean>(true);
const [shutdownLogs, setShutdownLogs] = useState<string[]>([]);
const [searchParams, setSearchParams] = useSearchParams();
const { t } = useTranslation();

useEffect(() => {
const key = searchParams.get("key");
Expand All @@ -43,7 +46,13 @@ export function Header() {
}, 1000);

useEffect(() => {
(async () => { triblerService.addEventListener("tribler_shutdown_state", OnShutdownEvent) })();
(async () => {
triblerService.addEventListener("tribler_shutdown_state", OnShutdownEvent) })();
triblerService.getNewVersion().then(
(result) => {
if (result) toast(t("VersionAvailable") + ": " + result, {icon: "ℹ", });},
(error) => {}
);
return () => {
(async () => { triblerService.removeEventListener("tribler_shutdown_state", OnShutdownEvent) })();
}
Expand Down Expand Up @@ -119,6 +128,13 @@ export function Header() {
</div>
</div>
</header>

<Toaster
position="bottom-left"
toastOptions={{
className: 'bg-accent text-foreground font-light',
}}
/>
</>
)
}
8 changes: 1 addition & 7 deletions src/tribler/ui/src/pages/Settings/SaveButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Button } from "@/components/ui/button";
import toast, { Toaster } from 'react-hot-toast';
import toast from 'react-hot-toast';
import { useTranslation } from "react-i18next";


Expand All @@ -26,12 +26,6 @@ export default function SaveButton(props: SaveButtonProps) {
return (
<>
<Button type="submit" className="mt-2" onClick={save}>{t('Save')}</Button>
<Toaster
position="bottom-left"
toastOptions={{
className: 'bg-accent text-foreground font-light',
}}
/>
</>
)
}

0 comments on commit 67d140d

Please sign in to comment.