Skip to content

Commit

Permalink
Fix restart button when Done
Browse files Browse the repository at this point in the history
When the flashing process completes the user is asked if they want to
flash another device. Currently the button seems to do nothing; these
changes return the app back to the start screen to allow the user to
attempt another flashing process.
  • Loading branch information
llewelld committed Apr 26, 2022
1 parent c86c0e3 commit 91ba393
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
10 changes: 10 additions & 0 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@
yumi.setPosition("center");
});
ipcRenderer.on("user:restart", () => {
push("/");
footerData.set({
topText: "Restarting",
underText: `UBports Installer is restarting`,
waitingDots: true
});
yumi.setPosition("foot");
});
//Error handling
// Catch all unhandled errors in rendering process
window.onerror = (err, url, line) => {
Expand Down
8 changes: 6 additions & 2 deletions src/core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,14 @@ class Core {
* @param {String} [file] config file
* @returns {Promise}
*/
prepare(file) {
prepare(file, restart) {
return Promise.all([
this.readConfigFile(file),
this.plugins.init().catch(e => errors.toUser(e, "initializing plugins"))
() => { return restart
? true
: this.plugins.init()
.catch(e => errors.toUser(e, "initializing plugins"))
}
]).then(() => {
if (this.props.config) {
this.selectOs();
Expand Down
8 changes: 5 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const mainEvent = require("./lib/mainEvent.js");
const reporter = require("./lib/reporter.js");
const menuManager = require("./lib/menuManager.js");
const core = require("./core/core.js");
const window = require("./lib/window.js");

// Enable live reload for Electron
if (process.env.ROLLUP_WATCH) {
Expand All @@ -48,8 +49,9 @@ ipcMain.on("reportResult", async (event, result, error) => {
// FIXME move after a better way to access mainWindow has been found
mainEvent.on("restart", () => {
log.info("UBports Installer restarting...");
core.kill();
mainWindow.reload();
window.send("user:restart")
core.reset();
core.prepare(cli.file, true)
});

async function createWindow() {
Expand Down Expand Up @@ -85,7 +87,7 @@ async function createWindow() {
});

// Tasks we need for every start and restart
mainWindow.webContents.on("did-finish-load", () => core.prepare(cli.file));
mainWindow.webContents.on("did-finish-load", () => core.prepare(cli.file, false));

// Task we need only on the first start
mainWindow.webContents.once("did-finish-load", () => {
Expand Down

0 comments on commit 91ba393

Please sign in to comment.