mirror of
https://github.com/nimbold/Firelink.git
synced 2026-09-10 09:45:44 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 765451f221 |
+5
-11
@@ -3996,9 +3996,6 @@ fn mark_main_window_startup_complete(app_handle: &tauri::AppHandle) {
|
||||
#[cfg(target_os = "windows")]
|
||||
fn reveal_main_window(app_handle: &tauri::AppHandle) {
|
||||
if let Some(window) = app_handle.get_webview_window("main") {
|
||||
if let Err(error) = window.set_focusable(true) {
|
||||
log::warn!("Could not make the main window focusable: {error}");
|
||||
}
|
||||
if let Err(error) = window.show() {
|
||||
eprintln!("Failed to reveal the main window: {error}");
|
||||
}
|
||||
@@ -18200,12 +18197,9 @@ fn toggle_log_pause(caller: tauri::WebviewWindow, pause: bool) -> Result<(), Str
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn is_log_paused() -> bool {
|
||||
// This read is needed during renderer bootstrap, including by standalone
|
||||
// Properties windows. Avoid extracting a WebviewWindow here: on Windows,
|
||||
// WebView2 can invoke the command while its host is still initializing.
|
||||
// Mutating logging commands remain restricted to the main window below.
|
||||
LOG_PAUSED.load(std::sync::atomic::Ordering::Relaxed)
|
||||
fn is_log_paused(caller: tauri::WebviewWindow) -> bool {
|
||||
properties_window::ensure_main_window(&caller).is_ok()
|
||||
&& LOG_PAUSED.load(std::sync::atomic::Ordering::Relaxed)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
@@ -18561,8 +18555,7 @@ pub fn run() {
|
||||
// re-enter that handler during native construction.
|
||||
main_window_builder = main_window_builder
|
||||
.visible(false)
|
||||
.focused(false)
|
||||
.focusable(false);
|
||||
.focused(false);
|
||||
}
|
||||
main_window_builder
|
||||
.build()
|
||||
@@ -19903,6 +19896,7 @@ pub fn run() {
|
||||
mark_main_window_startup_complete(app_handle);
|
||||
#[cfg(target_os = "windows")]
|
||||
reveal_main_window(app_handle);
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
restore_pending_main_window(app_handle);
|
||||
}
|
||||
#[cfg(target_os = "macos")]
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
} from "./store/useSettingsStore";
|
||||
import { isPermissionGranted, requestPermission, sendNotification } from '@tauri-apps/plugin-notification';
|
||||
import { WindowControls } from "./components/WindowControls";
|
||||
import { PropertiesWindowBridgeHost } from "./components/PropertiesWindowBridgeHost";
|
||||
import { useToast } from "./contexts/ToastContext";
|
||||
import { setLogStreamActive } from './utils/logger';
|
||||
import { updateDockBadge } from './utils/dockBadge';
|
||||
@@ -1286,6 +1287,7 @@ function App() {
|
||||
|
||||
{isAddModalOpen && <AddDownloadsModal />}
|
||||
|
||||
<PropertiesWindowBridgeHost />
|
||||
{isDeleteModalOpen && (
|
||||
<Suspense fallback={null}>
|
||||
<DeleteConfirmationModal />
|
||||
|
||||
+9
-59
@@ -16,29 +16,7 @@ import { invokeCommand as invoke } from './ipc';
|
||||
|
||||
const isPropertiesWindow = getCurrentWindow().label.startsWith('properties-');
|
||||
|
||||
// WebView2 can overflow its native call stack when the renderer sends IPC
|
||||
// during document bootstrapping. Keep all renderer-to-native startup work
|
||||
// behind the document load boundary, not just the first logger query. This is
|
||||
// also needed for Zustand persistence, whose module initialization reads the
|
||||
// native database before React mounts.
|
||||
const documentLoaded = new Promise<void>((resolve) => {
|
||||
const releaseAfterNativeLoad = () => {
|
||||
// The load event is dispatched from WebView2's navigation callback. Move
|
||||
// renderer startup to the next task so its first IPC cannot re-enter that
|
||||
// native callback stack.
|
||||
window.setTimeout(resolve, 0);
|
||||
};
|
||||
|
||||
if (document.readyState === 'complete') {
|
||||
releaseAfterNativeLoad();
|
||||
return;
|
||||
}
|
||||
window.addEventListener('load', releaseAfterNativeLoad, { once: true });
|
||||
});
|
||||
|
||||
void documentLoaded.then(() => {
|
||||
void initLogger();
|
||||
});
|
||||
void initLogger();
|
||||
|
||||
const serializeConsoleArguments = (values: unknown[]) => values.map(value => {
|
||||
if (value instanceof Error) return `${value.name}: ${value.message}\n${value.stack || ''}`;
|
||||
@@ -58,13 +36,11 @@ const originalConsoleError = console.error.bind(console);
|
||||
const originalConsoleWarn = console.warn.bind(console);
|
||||
console.error = (...values: unknown[]) => {
|
||||
originalConsoleError(...values);
|
||||
const message = redactConsoleMessage(serializeConsoleArguments(values));
|
||||
void documentLoaded.then(() => logError(message)).catch(() => undefined);
|
||||
void logError(redactConsoleMessage(serializeConsoleArguments(values))).catch(() => undefined);
|
||||
};
|
||||
console.warn = (...values: unknown[]) => {
|
||||
originalConsoleWarn(...values);
|
||||
const message = redactConsoleMessage(serializeConsoleArguments(values));
|
||||
void documentLoaded.then(() => logWarn(message)).catch(() => undefined);
|
||||
void logWarn(redactConsoleMessage(serializeConsoleArguments(values))).catch(() => undefined);
|
||||
};
|
||||
|
||||
const rootElement = document.getElementById("root");
|
||||
@@ -99,46 +75,20 @@ const PropertiesStartupFailure = () => (
|
||||
</main>
|
||||
);
|
||||
|
||||
const MainStartupFailure = () => (
|
||||
<main className="flex h-screen min-h-0 flex-col items-center justify-center gap-4 bg-main-bg p-6 text-text-primary">
|
||||
<p role="alert">Firelink could not be loaded.</p>
|
||||
<button
|
||||
type="button"
|
||||
className="app-button app-button-primary px-3 text-xs"
|
||||
onClick={() => {
|
||||
void getCurrentWindow().close().catch(error => {
|
||||
console.error('[MainStartupFailure] close failed', error);
|
||||
});
|
||||
}}
|
||||
>
|
||||
Close
|
||||
</button>
|
||||
</main>
|
||||
);
|
||||
|
||||
const renderMainApp = async () => {
|
||||
if (!rootElement) return;
|
||||
|
||||
await documentLoaded;
|
||||
|
||||
try {
|
||||
// Keep the child entrypoint isolated from the main application module. App
|
||||
// imports the persistent Zustand stores, whose module initialization issues
|
||||
// main-window-only IPC commands. Loading it in a Properties child creates a
|
||||
// second persistence owner and can race the bridge handshake.
|
||||
const RootComponent = (await import('./App')).default;
|
||||
renderRoot(RootComponent);
|
||||
} catch (error) {
|
||||
console.error('Failed to initialize Firelink:', error);
|
||||
renderRoot(MainStartupFailure);
|
||||
}
|
||||
// Keep the child entrypoint isolated from the main application module. App
|
||||
// imports the persistent Zustand stores, whose module initialization issues
|
||||
// main-window-only IPC commands. Loading it in a Properties child creates a
|
||||
// second persistence owner and can race the bridge handshake.
|
||||
const RootComponent = (await import('./App')).default;
|
||||
renderRoot(RootComponent);
|
||||
};
|
||||
|
||||
const renderPropertiesApp = async () => {
|
||||
if (!rootElement) return;
|
||||
|
||||
await documentLoaded;
|
||||
|
||||
try {
|
||||
// Properties starts with the synchronous English catalog and changes locale
|
||||
// after its first paint. Waiting for a lazy locale chunk here delays the
|
||||
|
||||
Reference in New Issue
Block a user