Changeset View
Changeset View
Standalone View
Standalone View
extension/extension.js
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Line(s) | 91 | path: { | |||
---|---|---|---|---|---|
92 | "16": "icons/plasma-disabled-16.png", | 92 | "16": "icons/plasma-disabled-16.png", | ||
93 | "32": "icons/plasma-disabled-32.png", | 93 | "32": "icons/plasma-disabled-32.png", | ||
94 | "48": "icons/plasma-disabled-48.png", | 94 | "48": "icons/plasma-disabled-48.png", | ||
95 | "128": "icons/plasma-disabled-128.png" | 95 | "128": "icons/plasma-disabled-128.png" | ||
96 | } | 96 | } | ||
97 | }); | 97 | }); | ||
98 | } | 98 | } | ||
99 | 99 | | |||
100 | if (portLastErrorMessage) { | 100 | if (portLastErrorMessage && receivedMessageOnce) { | ||
101 | chrome.browserAction.setBadgeText({ text: "!" }); | 101 | chrome.browserAction.setBadgeText({ text: "!" }); | ||
102 | chrome.browserAction.setBadgeBackgroundColor({ color: "#da4453" }); // breeze "negative" color | 102 | chrome.browserAction.setBadgeBackgroundColor({ color: "#da4453" }); // breeze "negative" color | ||
103 | } else { | 103 | } else { | ||
104 | chrome.browserAction.setBadgeText({ text: "" }); | 104 | chrome.browserAction.setBadgeText({ text: "" }); | ||
105 | } | 105 | } | ||
106 | } | 106 | } | ||
107 | updateBrowserAction(); | 107 | updateBrowserAction(); | ||
108 | 108 | | |||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | 172 | for (let device in kdeConnectDevices) { | |||
175 | } | 175 | } | ||
176 | chrome.contextMenus.remove(kdeConnectMenuIdPrefix + device); | 176 | chrome.contextMenus.remove(kdeConnectMenuIdPrefix + device); | ||
177 | } | 177 | } | ||
178 | } catch (e) { | 178 | } catch (e) { | ||
179 | console.warn("Failed to cleanup after port disconnect", e); | 179 | console.warn("Failed to cleanup after port disconnect", e); | ||
180 | } | 180 | } | ||
181 | kdeConnectDevices = {}; | 181 | kdeConnectDevices = {}; | ||
182 | 182 | | |||
183 | if (receivedMessageOnce) { | | |||
184 | portLastErrorMessage = error && error.message || "UNKNOWN"; | 183 | portLastErrorMessage = error && error.message || "UNKNOWN"; | ||
184 | if (receivedMessageOnce) { | ||||
185 | portStatus = "DISCONNECTED"; | 185 | portStatus = "DISCONNECTED"; | ||
186 | 186 | | |||
187 | console.log("Auto-restarting it"); | 187 | console.log("Auto-restarting it"); | ||
188 | connectHost(); | 188 | connectHost(); | ||
189 | } else { | 189 | } else { | ||
190 | portLastErrorMessage = ""; | | |||
191 | portStatus = "STARTUP_FAILED"; | 190 | portStatus = "STARTUP_FAILED"; | ||
192 | 191 | | |||
193 | console.warn("Not auto-restarting host as we haven't received any message from it before. Check that it's working/installed correctly"); | 192 | console.warn("Not auto-restarting host as we haven't received any message from it before. Check that it's working/installed correctly"); | ||
194 | } | 193 | } | ||
195 | updateBrowserAction(); | 194 | updateBrowserAction(); | ||
196 | }); | 195 | }); | ||
197 | 196 | | |||
198 | sendEnvironment(); | 197 | sendEnvironment(); | ||
Show All 38 Lines | 227 | addRuntimeCallback("browserAction", "ready", () => { | |||
237 | }); | 236 | }); | ||
238 | browserActionPort.onDisconnect.addListener((port) => { | 237 | browserActionPort.onDisconnect.addListener((port) => { | ||
239 | if (port.name !== "browserActionPort") { | 238 | if (port.name !== "browserActionPort") { | ||
240 | return; | 239 | return; | ||
241 | } | 240 | } | ||
242 | 241 | | |||
243 | // disabling the browser action immediately when opening it | 242 | // disabling the browser action immediately when opening it | ||
244 | // causes opening to fail on Firefox, so clear the error only when it's being closed. | 243 | // causes opening to fail on Firefox, so clear the error only when it's being closed. | ||
244 | // Only clear error when it was a transient error, not a startup failure | ||||
245 | if (receivedMessageOnce) { | ||||
245 | portLastErrorMessage = ""; | 246 | portLastErrorMessage = ""; | ||
246 | updateBrowserAction(); | 247 | updateBrowserAction(); | ||
248 | } | ||||
247 | }); | 249 | }); | ||
248 | }); | 250 | }); |