Commit 7b033c52 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

Show startup error in popup as well

When the host crashes, the error message is shown to the user. When startup fails, only a generic message is shown.
This adds the error message provided by the browser to aid debugging the problem.

Differential Revision: https://phabricator.kde.org/D25320
parent c1d7ea73
......@@ -33,6 +33,8 @@
<p data-i18n="general_error_startup_failed">I18N</p>
<h4 id="startup_error_text" class="hidden"></h4>
<a data-i18n="general_error_startup_failed_wiki_link" href="https://community.kde.org/Plasma/Browser_Integration" target="_blank">I18N</a>
</div>
......
......@@ -159,11 +159,20 @@ document.addEventListener("DOMContentLoaded", () => {
document.getElementById("unsupported_os_error").classList.remove("hidden");
break;
case "STARTUP_FAILED":
case "STARTUP_FAILED": {
document.getElementById("startup_error").classList.remove("hidden");
const errorText = status.portLastErrorMessage;
// Don't show generic error on startup failure. There's already an explanation.
if (errorText && errorText !== "UNKNOWN") {
const errorTextItem = document.getElementById("startup_error_text");
errorTextItem.innerText = errorText;
errorTextItem.classList.remove("hidden");
}
break;
}
default:
default: {
document.getElementById("main").classList.remove("hidden");
let errorText = status.portLastErrorMessage;
......@@ -181,6 +190,7 @@ document.addEventListener("DOMContentLoaded", () => {
break;
}
}
// HACK so the extension can tell we closed, see "browserAction" "ready" callback in extension.js
chrome.runtime.onConnect.addListener((port) => {
......
......@@ -97,7 +97,7 @@ function updateBrowserAction() {
});
}
if (portLastErrorMessage) {
if (portLastErrorMessage && receivedMessageOnce) {
chrome.browserAction.setBadgeText({ text: "!" });
chrome.browserAction.setBadgeBackgroundColor({ color: "#da4453" }); // breeze "negative" color
} else {
......@@ -180,14 +180,13 @@ function connectHost() {
}
kdeConnectDevices = {};
portLastErrorMessage = error && error.message || "UNKNOWN";
if (receivedMessageOnce) {
portLastErrorMessage = error && error.message || "UNKNOWN";
portStatus = "DISCONNECTED";
console.log("Auto-restarting it");
connectHost();
} else {
portLastErrorMessage = "";
portStatus = "STARTUP_FAILED";
console.warn("Not auto-restarting host as we haven't received any message from it before. Check that it's working/installed correctly");
......@@ -242,7 +241,10 @@ addRuntimeCallback("browserAction", "ready", () => {
// disabling the browser action immediately when opening it
// causes opening to fail on Firefox, so clear the error only when it's being closed.
portLastErrorMessage = "";
updateBrowserAction();
// Only clear error when it was a transient error, not a startup failure
if (receivedMessageOnce) {
portLastErrorMessage = "";
updateBrowserAction();
}
});
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment