Skip to content

Commit c9004dd

Browse files
authored
fix(app-shell, app-shell-odd): Report window type on hard refresh (#20156)
Closes RQA-4773 We report the window type when the app initially renders in App.tsx, and this window type determines the specific render tree for a given renderer process. However, we weren't reporting this when a user hard refreshes an app, because the report only happens on initial render. To fix, we can report the event on did-finish-load continuously after the initial window load.
1 parent 2865828 commit c9004dd

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

app-shell-odd/src/ui.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ export function waitForRobotServerAndShowMainWindow(
7070
): void {
7171
mainWindow.show()
7272
mainWindow.webContents.send('window-type', 'odd-main')
73+
74+
mainWindow.webContents.on('did-finish-load', () => {
75+
mainWindow.webContents.send('window-type', 'odd-main')
76+
})
77+
7378
_NODE_ENV_ !== 'development' &&
7479
setTimeout(function () {
7580
systemd

app-shell/src/secondary-windows/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ function openWindow(details: SecondaryWindowDetails): void {
137137
const newWindow = createUi()
138138
secondaryWindows.set(windowId, newWindow)
139139

140-
newWindow.webContents.once('did-finish-load', () => {
140+
newWindow.webContents.on('did-finish-load', () => {
141141
log.debug(`Did finish load for ${type}`)
142142
newWindow.webContents.send('window-type', 'secondary')
143143
})

app-shell/src/ui.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,18 @@ const WINDOW_OPTS = {
4343
export function createUi(): BrowserWindow {
4444
log.debug('Creating main window', { options: WINDOW_OPTS })
4545

46-
const mainWindow = new BrowserWindow(WINDOW_OPTS).once(
47-
'ready-to-show',
48-
() => {
49-
log.debug('Main window ready to show')
50-
mainWindow.show()
51-
mainWindow.webContents.send('window-type', 'desktop-main')
52-
}
53-
)
46+
const mainWindow = new BrowserWindow(WINDOW_OPTS)
47+
48+
mainWindow.once('ready-to-show', () => {
49+
log.debug('Main window ready to show')
50+
mainWindow.show()
51+
mainWindow.webContents.send('window-type', 'desktop-main')
52+
})
53+
54+
// For hard app refreshes.
55+
mainWindow.webContents.on('did-finish-load', () => {
56+
mainWindow.webContents.send('window-type', 'desktop-main')
57+
})
5458

5559
log.info(`Loading ${url}`)
5660
// eslint-disable-next-line @typescript-eslint/no-floating-promises

0 commit comments

Comments
 (0)