Skip to content

Commit

Permalink
reset button in global menu
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoTheThird committed Jun 3, 2022
1 parent 5a09ca7 commit 60d2710
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 40 deletions.
71 changes: 36 additions & 35 deletions src/core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,41 +78,42 @@ class Core {
prepare(file, restart = false) {
return Promise.all([
this.readConfigFile(file),
!restart &&
this.plugins.init().catch(e => errors.toUser(e, "initializing plugins"))
]).then(() => {
if (this.props.config) {
this.selectOs();
} else {
const wait = this.plugins
.wait()
.catch(e => errors.toUser(e, "plugin wait()"))
.then(device => api.resolveAlias(device))
.catch(
e =>
new Promise(() => {
log.debug(`failed to resolve device name: ${e}`);
mainEvent.emit("user:no-network");
})
)
.then(device => {
if (device) {
log.info(`device detected: ${device}`);
this.setDevice(device);
}
});
ipcMain.once("device:selected", () => (wait ? wait.cancel() : null));
api
.getDeviceSelects()
.then(out => {
window.send("device:wait:device-selects-ready", out);
})
.catch(e => {
log.error("getDeviceSelects error: " + e);
mainEvent.emit("user:no-network");
});
}
});
restart || this.plugins.init()
])
.catch(e => errors.toUser(e, "initialization"))
.then(() => {
if (this.props.config) {
this.selectOs();
} else {
const wait = this.plugins
.wait()
.catch(e => errors.toUser(e, "plugin wait()"))
.then(device => api.resolveAlias(device))
.catch(
e =>
new Promise(() => {
log.debug(`failed to resolve device name: ${e}`);
mainEvent.emit("user:no-network");
})
)
.then(device => {
if (device) {
log.info(`device detected: ${device}`);
this.setDevice(device);
}
});
ipcMain.once("device:selected", () => (wait ? wait.cancel() : null));
api
.getDeviceSelects()
.then(out => {
window.send("device:wait:device-selects-ready", out);
})
.catch(e => {
log.error("getDeviceSelects error: " + e);
mainEvent.emit("user:no-network");
});
}
});
}

/**
Expand Down
6 changes: 2 additions & 4 deletions src/core/plugins/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

/*
* Copyright (C) 2020-2021 UBports Foundation <[email protected]>
* Copyright (C) 2020-2022 UBports Foundation <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -115,9 +115,7 @@ class PluginIndex {
.init()
.then(initSuccessful => {
if (!initSuccessful) {
this.log.warn(
`Disabling plugin ${name} because it failed to initialize with result: ${initSuccessful}`
);
this.log.warn(`Failed to initialize plugin ${name}, disabling`);
delete this.plugins[name];
}
})
Expand Down
9 changes: 8 additions & 1 deletion src/lib/menuManager.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

/*
* Copyright (C) 2017-2020 UBports Foundation <[email protected]>
* Copyright (C) 2017-2022 UBports Foundation <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -23,6 +23,7 @@ const window = require("./window.js");
const udev = require("./udev.js");
const settings = require("./settings.js");
const cache = require("./cache.js");
const mainEvent = require("./mainEvent.js");
const reporter = require("./reporter.js");

class MenuManager {
Expand Down Expand Up @@ -121,6 +122,12 @@ class MenuManager {
settings.clear();
},
visible: settings.size
},
{
label: "Restart UBports Installer",
click: () => {
mainEvent.emit("restart");
}
}
]
},
Expand Down

0 comments on commit 60d2710

Please sign in to comment.