Skip to content

Commit

Permalink
Upgrade to React 18 (+associated fixes)
Browse files Browse the repository at this point in the history
  • Loading branch information
xanderfrangos committed Dec 28, 2023
1 parent aaec08d commit 6063739
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 43 deletions.
43 changes: 21 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,20 @@
}
},
"devDependencies": {
"@babel/core": "^7.13.8",
"@babel/plugin-proposal-class-properties": "^7.12.13",
"@babel/preset-env": "^7.13.8",
"@babel/preset-react": "^7.12.13",
"@babel/core": "^7.23.6",
"@babel/preset-env": "^7.23.6",
"@babel/runtime": "^7.23.6",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/preset-react": "^7.23.3",
"concurrently": "^5.3.0",
"cross-env": "^7.0.3",
"electron": "^26.6.2",
"electron-builder": "^24.9.1",
"node-gyp": "^9.4.0",
"parcel-bundler": "^1.12.5",
"react": "^17.0.0",
"react": "18.2.0",
"react-beautiful-dnd": "^13.1.0",
"react-dom": "^17.0.0",
"react-dom": "18.2.0",
"sass": "^1.54.0",
"wait-on": "^5.3.0"
},
Expand Down
3 changes: 3 additions & 0 deletions src/components/BrightnessPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,9 @@ export default class BrightnessPanel extends PureComponent {
// Update brightness every interval, if changed
this.resetBrightnessInterval()

window.requestSettings()
window.requestMonitors()
window.reactReady = true
}

componentDidUpdate() {
Expand Down
1 change: 1 addition & 0 deletions src/components/IntroWindow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default class IntroWindow extends PureComponent {

componentDidMount() {
window.addEventListener("localizationUpdated", (e) => { T.setLocalizationData(e.detail.desired, e.detail.default); this.forceUpdate() })
window.ipc.send('request-localization')
}

render() {
Expand Down
3 changes: 3 additions & 0 deletions src/components/SettingsWindow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ export default class SettingsWindow extends PureComponent {
window.checkForUpdates()
}
window.ipc.send('get-window-history')
window.ipc.send("sendSettingsWindowPos")
window.ipc.send('request-localization')
window.reactReady = true
}


Expand Down
6 changes: 2 additions & 4 deletions src/intro.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React from "react";
import ReactDOM from "react-dom";
import { createRoot } from 'react-dom/client';
import IntroWindow from "./components/IntroWindow";

window.ipc.send('request-localization')

ReactDOM.render(<IntroWindow />, document.getElementById("root"));
createRoot(document.getElementById("root")).render(<IntroWindow />)
2 changes: 2 additions & 0 deletions src/panel-preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ function updateBrightness(index, level) {
}

function detectSunValley() {
if(!window.reactReady) return false;
try {
// Detect new Fluent Icons (Windows build 21327+)
if(window.settings.enableSunValley && document.fonts.check("12px Segoe Fluent Icons")) {
Expand Down Expand Up @@ -442,6 +443,7 @@ window.allMonitors = []
window.lastUpdate = Date.now()
window.showPanel = false
window.isAcrylic = false
window.reactReady = false
window.theme = "dark"
window.settings = {}
window.jsVars = getArgumentVars()
Expand Down
7 changes: 2 additions & 5 deletions src/panel.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import React from "react";
import ReactDOM from "react-dom";
import { createRoot } from 'react-dom/client';
import BrightnessPanel from "./components/BrightnessPanel";

if (window.settings == undefined) window.settings = {}

window.ipc.send('request-localization')

ReactDOM.render(<BrightnessPanel monitors={window.allMonitors} lastUpdate={window.lastUpdate} />, document.getElementById("root"), () => {
requestSettings()
requestMonitors()
});
createRoot(document.getElementById("root")).render(<BrightnessPanel monitors={window.allMonitors} lastUpdate={window.lastUpdate} />)

window.updateMica = () => {
const pos = [window.winPosition[0], window.winPosition[1]]
Expand Down
2 changes: 2 additions & 0 deletions src/settings-preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ function resetSettings() {
}

function detectSunValley() {
if(!window.reactReady) return false;
try {
// Detect new Fluent Icons (Windows build 21327+)
if(window.settings.enableSunValley && document.fonts.check("12px Segoe Fluent Icons")) {
Expand Down Expand Up @@ -254,6 +255,7 @@ window.openURL = openURL
window.allMonitors = []
window.lastUpdate = Date.now()
window.showPanel = false
window.reactReady = false
window.settings = getArgumentVars().settings
window.accent = "cyan"
window.getSunCalcTimes = getSunCalcTimes
Expand Down
8 changes: 2 additions & 6 deletions src/settings.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import React from "react";
import ReactDOM from "react-dom";
import { createRoot } from 'react-dom/client';
import SettingsWindow from "./Components/SettingsWindow";

window.ipc.send('request-localization')

const micaDisplays = document.querySelector("#mica .displays")

function updateMicaPosition(pos = [0, 0]) {
Expand All @@ -21,6 +19,4 @@ window.addEventListener("focus", () => {
document.body.dataset.focused = "true"
})

ReactDOM.render(<SettingsWindow theme={window.settings.theme} />, document.getElementById("settings"));

window.ipc.send("sendSettingsWindowPos")
createRoot(document.getElementById("settings")).render(<SettingsWindow theme={window.settings.theme} />)

0 comments on commit 6063739

Please sign in to comment.