Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WS-689] minimize white flashes #101

Merged
merged 3 commits into from
Aug 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/createWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,13 @@ export function createWindow(props?: WindowProps): BrowserWindow {
minHeight: 420,
backgroundColor,
autoHideMenuBar: true, // Window & Linux only, hides the menubar unless `Alt` is held
show: false, // We're starting with the window hidden, as we are still setting it up using imperative methods below
...platformStyling,
});

// Add a custom string to user agent to make it easier to differentiate requests from desktop app
window.webContents.setUserAgent(
`${window.webContents.getUserAgent()} ReplitDesktop`
`${window.webContents.getUserAgent()} ReplitDesktop`,
);

// Prevent any URLs opened via a target="_blank" anchor tag or programmatically using `window.open` from
Expand Down Expand Up @@ -143,7 +144,7 @@ export function createWindow(props?: WindowProps): BrowserWindow {
});

// If the previous bounds are no longer in-bounds with the current set of
// displays, then bail and fallback to the defaul behavior to prevent the app
// displays, then bail and fallback to the default behavior to prevent the app
// from opening stretched out or sticking outside the screens.
const inBounds = isInBounds(store.getWindowBounds());

Expand All @@ -156,7 +157,7 @@ export function createWindow(props?: WindowProps): BrowserWindow {
window.on("close", async () => {
// We're capturing the background color to use as main browser window background color.
const backgroundColor = await window.webContents.executeJavaScript(
`getComputedStyle(document.body).getPropertyValue('--background-root');`
`getComputedStyle(document.body).getPropertyValue('--background-root');`,
);
store.setLastSeenBackgroundColor(backgroundColor);
store.setWindowBounds(window.getBounds());
Expand All @@ -180,5 +181,8 @@ export function createWindow(props?: WindowProps): BrowserWindow {
// See: https://github.com/electron/electron/issues/1360#issuecomment-156506130
window.loadURL(url, { extraHeaders: "pragma: no-cache\n" });

// We've set up the window, so let's show it!
window.show();

return window;
}