Skip to content

Commit

Permalink
Merge branch 'beta' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Jul 3, 2023
2 parents 9a7cea8 + 94fab24 commit be0f083
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 34 deletions.
2 changes: 1 addition & 1 deletion bundled-modules
Submodule bundled-modules updated 109 files
6 changes: 3 additions & 3 deletions launcher/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ if (!lock) {
line = stripAnsi(line.trim())
if (prefix) line = `${new Date().toISOString()} ${prefix}: ${line}`

logStream.write(line)
logStream.write(line + '\n')
console.log(line)
}

Expand Down Expand Up @@ -644,9 +644,9 @@ if (!lock) {

if (selected == 1) {
app.exit(1)
} else {
} else if (fs.existsSync(thisDbPath)) {
// Mark the current config as most recently modified
fs.utimesSync(path.join(configDir, dirname, 'db'), Date.now(), Date.now())
fs.utimesSync(thisDbPath, Date.now(), Date.now())
}
}

Expand Down
22 changes: 13 additions & 9 deletions lib/Service/EmberPlus.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,10 @@ class ServiceEmberPlus extends ServiceBase {
let bank = parseInt(pathInfo[3])

if (!isNaN(page) && !isNaN(bank) && page > 0 && page < 100) {
this.logger.silly('Change bank ' + page + '.' + bank + ' to', value)
this.bank.action.pressBank(page, bank, value, 'emberplus')
const controlId = CreateBankControlId(page, bank)
this.logger.silly(`Change bank ${controlId} text to`, value)

this.controls.pressControl(controlId, !!value, `emberplus`)
this.server.update(parameter, { value })
return true
}
Expand All @@ -214,13 +216,15 @@ class ServiceEmberPlus extends ServiceBase {
let bank = parseInt(pathInfo[3])

if (!isNaN(page) && !isNaN(bank) && page > 0 && page < 100) {
this.logger.silly('Change bank ' + page + '.' + bank + ' text to', value)
if (this.banks[page] && this.banks[page][bank]) {
if (value !== this.banks[page][bank].text) {
this.bank.changeField(page, bank, 'text', value)
this.server.update(parameter, { value })
return true
}
const controlId = CreateBankControlId(page, bank)
this.logger.silly(`Change bank ${controlId} text to`, value)

const control = this.controls.getControl(controlId)
if (control && typeof control.styleSetFields === 'function') {
control.styleSetFields({ text: value })
// Note: this will be replaced shortly after with the value with feedbacks applied
this.server.update(parameter, { value })
return true
}
}
}
Expand Down
12 changes: 7 additions & 5 deletions lib/UI/Handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ class UIHandler {
clientConnect(client) {
this.logger.debug('socket ' + client.id + ' connected')

client.emit('app-version-info', {
appVersion: this.registry.appVersion,
appBuild: this.registry.appBuild,
})

// Wrap all 'client.on' calls, so that we 'handle' any errors they might throw
const originalOn = client.on.bind(client)
client.on = (name, fcn) => {
Expand Down Expand Up @@ -80,6 +75,13 @@ class UIHandler {
})
}

client.onPromise('app-version-info', () => {
return {
appVersion: this.registry.appVersion,
appBuild: this.registry.appBuild,
}
})

this.registry.log.clientConnect(client)
this.registry.ui.clientConnect(client)
this.registry.data.clientConnect(client)
Expand Down
26 changes: 13 additions & 13 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,9 @@ program.command('start', { isDefault: true, hidden: true }).action(() => {
}
}

// machid is always in the configDir
// some files are always in the root configDir
const machineIdPath = path.join(configDir, 'machid')

// Make sure README file exists in the config dir
const readmePath = path.join(configDir, 'README.txt')
if (!fs.existsSync(readmePath)) {
fs.writeFileSync(
readmePath,
'Since Companion 3.0, each release your config gets put into a new folder.\n' +
'This makes it much easier and safer to downgrade to older releases, as their configuration will be left untouched.\n' +
"When launching a version whose folder doesn't yet exist, the config will be copied from one of the previous releases, looking in release order.\n" +
'\n' +
'The db file in this folder is used for 2.4 or older, use the appropriate folders for newer configs\n'
)
}

// Handle the rename from `develop` to `v3.0`, setting up a link for backwards compatibility
const developDir = path.join(configDir, 'develop')
Expand All @@ -137,6 +125,18 @@ program.command('start', { isDefault: true, hidden: true }).action(() => {
process.exit(1)
}

// Make sure README file exists in the config dir
if (!fs.existsSync(readmePath)) {
fs.writeFileSync(
readmePath,
'Since Companion 3.0, each release your config gets put into a new folder.\n' +
'This makes it much easier and safer to downgrade to older releases, as their configuration will be left untouched.\n' +
"When launching a version whose folder doesn't yet exist, the config will be copied from one of the previous releases, looking in release order.\n" +
'\n' +
'The db file in this folder is used for 2.4 or older, use the appropriate folders for newer configs\n'
)
}

// copy an older db if needed
if (configDir !== rootConfigDir && !fs.existsSync(path.join(configDir, 'db'))) {
// try and import the non-develop copy. we only need to take `db` for this
Expand Down
12 changes: 9 additions & 3 deletions webui/src/Layout/Header.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useContext, useEffect, useState } from 'react'
import { CHeader, CHeaderBrand, CHeaderNavItem, CHeaderNav, CHeaderNavLink, CToggler } from '@coreui/react'
import { SocketContext } from '../util'
import { SocketContext, socketEmitPromise } from '../util'
import { faLock } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'

Expand All @@ -12,12 +12,18 @@ export function MyHeader({ toggleSidebar, canLock, setLocked }) {

useEffect(() => {
if (socket) {
socket.on('app-version-info', setVersionInfo)
socket.on('app-update-info', setUpdateData)
socket.emit('app-update-info')

socketEmitPromise(socket, 'app-version-info', [])
.then((info) => {
setVersionInfo(info)
})
.catch((e) => {
console.error('Failed to load version info', e)
})

return () => {
socket.off('app-version-info', setVersionInfo)
socket.off('app-update-info', setUpdateData)
}
}
Expand Down

0 comments on commit be0f083

Please sign in to comment.