Skip to content

Commit 93c7b5a

Browse files
authored
Merge pull request #535 from ZIMkaRU/feature/make-two-loading-wins-for-startup-and-common-as-modal
Make two loading windows for startup and common as modal
2 parents 205f0b2 + d05bf61 commit 93c7b5a

17 files changed

+689
-453
lines changed

src/auto-updater/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const isMac = process.platform === 'darwin'
1818
const log = require('../error-manager/log')
1919
const BfxMacUpdater = require('./bfx.mac.updater')
2020
const wins = require('../window-creators/windows')
21+
const WINDOW_NAMES = require('../window-creators/window.names')
2122
const {
2223
showLoadingWindow,
2324
hideLoadingWindow
@@ -291,6 +292,7 @@ const _autoUpdaterFactory = () => {
291292

292293
autoUpdater.addInstallingUpdateEventHandler(() => {
293294
return showLoadingWindow({
295+
windowName: WINDOW_NAMES.LOADING_WINDOW,
294296
description: i18next.t('autoUpdater.loadingWindow.description'),
295297
isRequiredToCloseAllWins: true
296298
})
@@ -330,7 +332,10 @@ const _autoUpdaterFactory = () => {
330332

331333
isProgressToastEnabled = false
332334

333-
await hideLoadingWindow({ isRequiredToShowMainWin: false })
335+
await hideLoadingWindow({
336+
windowName: WINDOW_NAMES.LOADING_WINDOW,
337+
isRequiredToShowMainWin: false
338+
})
334339

335340
_switchMenuItem({
336341
isCheckMenuItemDisabled: false,

src/enforce-macos-app-location.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const {
88
showLoadingWindow,
99
hideLoadingWindow
1010
} = require('./window-creators/change-loading-win-visibility-state')
11+
const WINDOW_NAMES = require('./window-creators/window.names')
1112

1213
module.exports = async () => {
1314
if (
@@ -47,12 +48,11 @@ module.exports = async () => {
4748
}
4849

4950
await showLoadingWindow({
51+
windowName: WINDOW_NAMES.STARTUP_LOADING_WINDOW,
5052
description: i18next
5153
.t('enforceMacOSAppLocation.loadingWindow.description'),
5254
isRequiredToCloseAllWins: true,
53-
isIndeterminateMode: true,
54-
shouldCloseBtnBeShown: true,
55-
shouldMinimizeBtnBeShown: true
55+
isIndeterminateMode: true
5656
})
5757

5858
app.moveToApplicationsFolder({
@@ -76,5 +76,7 @@ module.exports = async () => {
7676
}
7777
})
7878

79-
await hideLoadingWindow()
79+
await hideLoadingWindow({
80+
windowName: WINDOW_NAMES.STARTUP_LOADING_WINDOW
81+
})
8082
}

src/export-db.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const {
1414
setLoadingDescription
1515
} = require('./window-creators/change-loading-win-visibility-state')
1616
const wins = require('./window-creators/windows')
17+
const WINDOW_NAMES = require('./window-creators/window.names')
1718
const isMainWinAvailable = require('./helpers/is-main-win-available')
1819
const {
1920
DEFAULT_ARCHIVE_DB_FILE_NAME,
@@ -39,8 +40,8 @@ module.exports = ({
3940
const secretKeyPath = path.join(pathToUserData, SECRET_KEY_FILE_NAME)
4041

4142
return async () => {
42-
const win = isMainWinAvailable(wins.mainWindow)
43-
? wins.mainWindow
43+
const win = isMainWinAvailable(wins[WINDOW_NAMES.MAIN_WINDOW])
44+
? wins[WINDOW_NAMES.MAIN_WINDOW]
4445
: BrowserWindow.getFocusedWindow()
4546

4647
try {
@@ -69,6 +70,7 @@ module.exports = ({
6970
}
7071

7172
await showLoadingWindow({
73+
windowName: WINDOW_NAMES.LOADING_WINDOW,
7274
description: i18next
7375
.t('exportDB.loadingWindow.description')
7476
})
@@ -90,7 +92,11 @@ module.exports = ({
9092
: ''
9193
const description = `${_description}${archived}`
9294

93-
await setLoadingDescription({ progress, description })
95+
await setLoadingDescription({
96+
windowName: WINDOW_NAMES.LOADING_WINDOW,
97+
progress,
98+
description
99+
})
94100
}
95101

96102
await zip(filePath, [
@@ -99,7 +105,9 @@ module.exports = ({
99105
dbWalPath,
100106
secretKeyPath
101107
], { progressHandler })
102-
await hideLoadingWindow()
108+
await hideLoadingWindow({
109+
windowName: WINDOW_NAMES.LOADING_WINDOW
110+
})
103111

104112
await showMessageModalDialog(win, {
105113
buttons: [
@@ -111,7 +119,9 @@ module.exports = ({
111119
})
112120
} catch (err) {
113121
try {
114-
await hideLoadingWindow()
122+
await hideLoadingWindow({
123+
windowName: WINDOW_NAMES.LOADING_WINDOW
124+
})
115125
await showErrorModalDialog(
116126
win,
117127
i18next.t('exportDB.modalDialog.title'),

src/import-db.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const pauseApp = require('./pause-app')
1313
const relaunch = require('./relaunch')
1414
const { rm, isMainWinAvailable } = require('./helpers')
1515
const wins = require('./window-creators/windows')
16+
const WINDOW_NAMES = require('./window-creators/window.names')
1617
const {
1718
setLoadingDescription
1819
} = require('./window-creators/change-loading-win-visibility-state')
@@ -44,8 +45,8 @@ module.exports = ({
4445
pathToUserDocuments
4546
}) => {
4647
return async () => {
47-
const win = isMainWinAvailable(wins.mainWindow)
48-
? wins.mainWindow
48+
const win = isMainWinAvailable(wins[WINDOW_NAMES.MAIN_WINDOW])
49+
? wins[WINDOW_NAMES.MAIN_WINDOW]
4950
: BrowserWindow.getFocusedWindow()
5051

5152
try {
@@ -99,7 +100,11 @@ module.exports = ({
99100
: ''
100101
const description = `${_description}${unzipped}`
101102

102-
await setLoadingDescription({ progress, description })
103+
await setLoadingDescription({
104+
windowName: WINDOW_NAMES.LOADING_WINDOW,
105+
progress,
106+
description
107+
})
103108
}
104109

105110
await pauseApp({
@@ -130,8 +135,8 @@ module.exports = ({
130135
relaunch()
131136
} catch (err) {
132137
try {
133-
const _win = isMainWinAvailable(wins.loadingWindow)
134-
? wins.loadingWindow
138+
const _win = isMainWinAvailable(wins[WINDOW_NAMES.LOADING_WINDOW])
139+
? wins[WINDOW_NAMES.LOADING_WINDOW]
135140
: win
136141
await showErrorModalDialog(
137142
_win,

src/initialize-app.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const {
2828
const {
2929
hideLoadingWindow
3030
} = require('./window-creators/change-loading-win-visibility-state')
31+
const WINDOW_NAMES = require('./window-creators/window.names')
3132
const makeOrReadSecretKey = require('./make-or-read-secret-key')
3233
const {
3334
configsKeeperFactory
@@ -53,10 +54,6 @@ const manageWorkerMessages = require(
5354
)
5455
const printToPDF = require('./print-to-pdf')
5556

56-
const pathToLayouts = path.join(__dirname, 'window-creators/layouts')
57-
const pathToLayoutAppInitErr = path
58-
.join(pathToLayouts, 'app-init-error.html')
59-
6057
const { rule: schedulerRule } = require(
6158
'../bfx-reports-framework/config/schedule.json'
6259
)
@@ -218,14 +215,17 @@ module.exports = async () => {
218215
manageWorkerMessages(ipc)
219216
await isServerReadyPromise
220217
await triggerSyncAfterUpdates()
221-
await hideLoadingWindow({ isRequiredToShowMainWin: true })
218+
await hideLoadingWindow({
219+
windowName: WINDOW_NAMES.STARTUP_LOADING_WINDOW,
220+
isRequiredToShowMainWin: true
221+
})
222222
await triggerElectronLoad(portsMap)
223223
await checkForUpdatesAndNotify()
224224

225225
printToPDF()
226226
} catch (err) {
227227
await app.whenReady()
228-
await createErrorWindow(pathToLayoutAppInitErr)
228+
await createErrorWindow()
229229

230230
throw err
231231
}

src/pause-app.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const ipcs = require('./ipcs')
44
const {
55
showLoadingWindow
66
} = require('./window-creators/change-loading-win-visibility-state')
7+
const WINDOW_NAMES = require('./window-creators/window.names')
78

89
const _closeServer = () => {
910
return new Promise((resolve, reject) => {
@@ -35,6 +36,7 @@ module.exports = async (opts) => {
3536
} = opts ?? {}
3637

3738
await showLoadingWindow({
39+
windowName: WINDOW_NAMES.LOADING_WINDOW,
3840
isRequiredToCloseAllWins: true,
3941
...loadingWinParams
4042
})

0 commit comments

Comments
 (0)