Skip to content

Commit 94f5be3

Browse files
authored
Merge pull request #1671 from nextcloud/refactor/welcome-ts
refactor(welcome): migrate to ts
2 parents 42bcc8d + d645c0c commit 94f5be3

File tree

4 files changed

+22
-25
lines changed

4 files changed

+22
-25
lines changed

forge.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ module.exports = {
438438
{
439439
name: 'talk_desktop__window_welcome',
440440
html: './src/welcome/welcome.html',
441-
js: './src/welcome/welcome.js',
441+
js: './src/welcome/welcome.main.ts',
442442
preload: {
443443
js: './src/preload.js',
444444
},

src/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const { installVueDevtools } = require('./install-vue-devtools.js')
3030
const { BUILD_CONFIG } = require('./shared/build.config.ts')
3131
const { createTalkWindow } = require('./talk/talk.window.js')
3232
const { createUpgradeWindow } = require('./upgrade/upgrade.window.ts')
33-
const { createWelcomeWindow } = require('./welcome/welcome.window.js')
33+
const { createWelcomeWindow } = require('./welcome/welcome.window.ts')
3434

3535
const argv = mri(process.argv.slice(app.isPackaged ? 1 : 2))
3636

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*!
22
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
@@ -11,19 +11,19 @@ import { applyAxiosInterceptors } from '../shared/setupWebPage.js'
1111

1212
import '@global-styles/dist/icons.css'
1313

14-
const quitButton = document.querySelector('.quit')
14+
const quitButton = document.querySelector<HTMLButtonElement>('.quit')!
1515
quitButton.addEventListener('click', () => window.TALK_DESKTOP.quit())
1616

1717
if (__CHANNEL__ !== 'stable') {
18-
document.querySelector('.footer').textContent = __VERSION_TAG__
18+
document.querySelector<HTMLDivElement>('.footer')!.textContent = __VERSION_TAG__
1919
}
2020

21-
window.TALK_DESKTOP.getSystemInfo().then((os) => {
22-
quitButton.classList.remove('hidden')
23-
if (os.isMac) {
24-
quitButton.classList.add('quit_mac')
25-
}
26-
})
21+
window.TALK_DESKTOP.systemInfo = await window.TALK_DESKTOP.getSystemInfo() as { isMac: boolean }
22+
23+
quitButton.classList.remove('hidden')
24+
if (window.TALK_DESKTOP.systemInfo.isMac) {
25+
quitButton.classList.add('quit_mac')
26+
}
2727

2828
appData.restore()
2929

@@ -37,7 +37,8 @@ if (appData.credentials) {
3737
// TODO: replace with a proper migration when the migration system supports it
3838
await initAppConfig()
3939
const accounts = getAppConfigValue('accounts')
40-
if (!accounts.length) {
40+
if (!accounts?.length) {
41+
// @ts-expect-error - appData is not typed yet
4142
await setAppConfigValue('accounts', [`${appData.credentials.user}@${appData.serverUrl.replace(/^https?:\/\//, '')}`])
4243
}
4344
}
Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
/**
1+
/*!
22
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6-
const { BrowserWindow } = require('electron')
7-
const { getAppConfig } = require('../app/AppConfig.ts')
8-
const { isMac } = require('../app/system.utils.ts')
9-
const { getScaledWindowSize, applyZoom, getWindowUrl } = require('../app/utils.ts')
10-
const { BUILD_CONFIG } = require('../shared/build.config.ts')
11-
const { getBrowserWindowIcon } = require('../shared/icons.utils.js')
6+
import { BrowserWindow } from 'electron'
7+
import { getAppConfig } from '../app/AppConfig.ts'
8+
import { isMac } from '../app/system.utils.ts'
9+
import { applyZoom, getScaledWindowSize, getWindowUrl } from '../app/utils.ts'
10+
import { BUILD_CONFIG } from '../shared/build.config.ts'
11+
import { getBrowserWindowIcon } from '../shared/icons.utils.js'
1212

1313
/**
14-
* @return {import('electron').BrowserWindow}
14+
* Creates the welcome window
1515
*/
16-
function createWelcomeWindow() {
16+
export function createWelcomeWindow() {
1717
const zoomFactor = getAppConfig('zoomFactor')
1818
const window = new BrowserWindow({
1919
...getScaledWindowSize({
@@ -46,7 +46,3 @@ function createWelcomeWindow() {
4646

4747
return window
4848
}
49-
50-
module.exports = {
51-
createWelcomeWindow,
52-
}

0 commit comments

Comments
 (0)