mirror of
https://github.com/vrc-get/vrc-get.git
synced 2026-06-21 09:58:08 +00:00
fix: toast are not shown because of delay in webview2 initialization
This commit is contained in:
parent
ccd252f8aa
commit
f44633a2ad
1 changed files with 14 additions and 3 deletions
|
|
@ -3,7 +3,7 @@
|
|||
import { QueryClientProvider } from "@tanstack/react-query";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import type React from "react";
|
||||
import { Suspense, useCallback, useEffect } from "react";
|
||||
import { Suspense, useCallback, useEffect, useEffectEvent } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { ToastContainer } from "react-toastify";
|
||||
import Loading from "@/app/-loading";
|
||||
|
|
@ -27,8 +27,7 @@ import { useTauriListen } from "@/lib/use-tauri-listen";
|
|||
export function Providers({ children }: { children: React.ReactNode }) {
|
||||
const navigate = useNavigate();
|
||||
|
||||
useTauriListen<LogEntry>("log", (event) => {
|
||||
const entry = event.payload as LogEntry;
|
||||
const showToastForLog = useEffectEvent((entry: LogEntry) => {
|
||||
if (entry.level === "Error" && (entry.gui_toast ?? true)) {
|
||||
toastError(entry.message);
|
||||
} else if (entry.level === "Warn" && (entry.gui_toast ?? false)) {
|
||||
|
|
@ -36,6 +35,18 @@ export function Providers({ children }: { children: React.ReactNode }) {
|
|||
}
|
||||
});
|
||||
|
||||
useTauriListen<LogEntry>("log", (event) => {
|
||||
showToastForLog(event.payload);
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
commands.utilGetLogEntries().then((value) => {
|
||||
for (const entry of value) {
|
||||
showToastForLog(entry);
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
||||
const moveToRepositories = useCallback(() => {
|
||||
if (location.pathname !== "/packages/repositories") {
|
||||
navigate({ to: "/packages/repositories" });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue