Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

✨ Small tweaks to the local url fallback logic

Alicia Sykesa574fa1c1037
diff --git a/docs/configuring.md b/docs/configuring.md
index 7517d446..87366f55 100644
--- a/docs/configuring.md
+++ b/docs/configuring.md
@@ -265,9 +265,9 @@ For more info, see the **[Authentication Docs](/docs/authentication.md)**
**`title`** | `string` | Required | The text to display/ title of a given item. Max length `18`
**`description`** | `string` | _Optional_ | Additional info about an item, which is shown in the tooltip on hover, or visible on large tiles
**`url`** | `string` | _Optional_ | The URL / location of web address for when the item is clicked
-**`localUrl`** | `string` | _Optional_ | An alternative URL (e.g. a LAN address) that is preferred whenever it is reachable from your browser. On page load Dashy probes this URL in the background; if it responds, clicking the item opens `localUrl`, otherwise it falls back to `url`. Ideal for local-vs-remote access (Tailscale, VPN, reverse-proxy, etc). The probe runs in the background so it never delays a click
-**`localUrlTimeout`** | `number` | _Optional_ | Milliseconds to wait for the `localUrl` reachability probe before giving up and using `url`. Clamped between `300` and `5000`. Defaults to `1500`
-**`localUrlCheckInterval`** | `number` | _Optional_ | Seconds between background re-checks of `localUrl`. `0` means only check on page load and when the browser tab regains focus. Clamped to `300` max. Defaults to `0`
+**`localUrl`** | `string` | _Optional_ | An alternative URL (e.g. a LAN address) that is preferred whenever it is reachable from your browser
+**`localUrlTimeout`** | `number` | _Optional_ | Milliseconds to wait for the `localUrl` reachability probe before giving up and using `url`. Between `300` and `5000`. Defaults to `1500`
+**`localUrlCheckInterval`** | `number` | _Optional_ | Seconds between background re-checks of `localUrl`. `0` means only check on page load and when the browser tab regains focus. `300` max. Defaults to `0`
**`icon`** | `string` | _Optional_ | The icon for a given item. Can be a font-awesome icon, favicon, remote URL or local URL. See [`item.icon`](#sectionicon-and-sectionitemicon)
**`target`** | `string` | _Optional_ | The opening method for when the item is clicked, either `newtab`, `sametab`, `modal`, `workspace`, `clipboard`, `top` or `parent`. Where `newtab` will open the link in a new tab, `sametab` will open it in the current tab, and `modal` will open a pop-up modal, `workspace` will open in the Workspace view and `clipboard` will copy the URL to system clipboard (but not launch app). Defaults to `newtab`
**`hotkey`** | `number` | _Optional_ | Give frequently opened applications a numeric hotkey, between `0 - 9`. You can then just press that key to launch that application.
diff --git a/src/components/LinkItems/Item.vue b/src/components/LinkItems/Item.vue
index 8c2d8495..5ac9ace1 100644
--- a/src/components/LinkItems/Item.vue
+++ b/src/components/LinkItems/Item.vue
@@ -218,17 +218,11 @@ export default {
this.intervalId = setInterval(this.checkWebsiteStatus, this.statusCheckInterval * 1000);
}
}
- // If an alternative local URL is set, probe its reachability in the background
- if (this.hasLocalUrl) {
- this.startLocalUrlChecks();
- }
},
beforeUnmount() {
// Stop periodic ping-check and status-check when item is destroyed (e.g. navigating in multi-page setup)
if (this.pingIntervalId) clearInterval(this.pingIntervalId);
if (this.intervalId) clearInterval(this.intervalId);
- // Stop local-URL probing timers and listeners
- this.stopLocalUrlChecks();
},
};
</script>
diff --git a/src/components/LinkItems/SubItem.vue b/src/components/LinkItems/SubItem.vue
index accb1579..3235ec23 100644
--- a/src/components/LinkItems/SubItem.vue
+++ b/src/components/LinkItems/SubItem.vue
@@ -56,15 +56,6 @@ export default {
return {};
},
methods: {},
- mounted() {
- // If an alternative local URL is set, probe its reachability in the background
- if (this.hasLocalUrl) {
- this.startLocalUrlChecks();
- }
- },
- beforeUnmount() {
- this.stopLocalUrlChecks();
- },
};
</script>
diff --git a/src/mixins/ItemMixin.js b/src/mixins/ItemMixin.js
index 91188bf1..e227feef 100644
--- a/src/mixins/ItemMixin.js
+++ b/src/mixins/ItemMixin.js
@@ -25,9 +25,9 @@ export default {
contextMenuOpen: false,
intervalId: undefined, // status-check setInterval() id
pingIntervalId: undefined, // ping-check setInterval() id
- // Local URL reachability: undefined = not yet probed, true/false = last result
- localUrlReachable: undefined,
+ localUrlReachable: undefined, // Locally reachable? unset if not yet probed, else true/false
localUrlIntervalId: undefined, // local-url re-check setInterval() id
+ localUrlController: undefined, // AbortController for the in-flight probe
contextPos: {
posX: undefined,
posY: undefined,
@@ -239,15 +239,13 @@ export default {
});
}
},
- /* Probes the configured local URL from the browser to decide if it's reachable.
- Runs in the background (never blocks a click): the result feeds `effectiveUrl`,
- which is already bound to the anchor's href by the time the user clicks.
- Uses a no-cors fetch so cross-origin LAN services don't trip CORS β€” we only
- care whether the request settles (reachable) or aborts/errors (unreachable). */
+ /* Probes the configured local URL from the browser to decide if it's reachable */
probeLocalUrl() {
if (!this.hasLocalUrl) return;
const target = this.item.localUrl.trim();
+ if (this.localUrlController) this.localUrlController.abort();
const controller = new AbortController();
+ this.localUrlController = controller;
const timer = setTimeout(() => controller.abort(), this.localUrlProbeTimeout);
fetch(target, {
mode: 'no-cors',
@@ -256,7 +254,10 @@ export default {
})
.then(() => { this.localUrlReachable = true; })
.catch(() => { this.localUrlReachable = false; })
- .finally(() => clearTimeout(timer));
+ .finally(() => {
+ clearTimeout(timer);
+ if (this.localUrlController === controller) this.localUrlController = undefined;
+ });
},
/* Starts local-URL probing: once now, on tab re-focus, and optionally on an interval */
startLocalUrlChecks() {
@@ -272,9 +273,10 @@ export default {
onVisibilityProbe() {
if (document.visibilityState === 'visible') this.probeLocalUrl();
},
- /* Tears down local-URL probing timers and listeners */
+ /* Tears down local-URL probing timers, listeners and any in-flight probe */
stopLocalUrlChecks() {
if (this.localUrlIntervalId) clearInterval(this.localUrlIntervalId);
+ if (this.localUrlController) this.localUrlController.abort();
document.removeEventListener('visibilitychange', this.onVisibilityProbe);
},
/* Called when an item is clicked, manages the opening of modal & resets the search field */
@@ -387,4 +389,12 @@ export default {
} catch { /* ignore corrupt localStorage */ }
},
},
+ mounted() {
+ // If an alternative local URL is set, probe its reachability in the background
+ if (this.hasLocalUrl) this.startLocalUrlChecks();
+ },
+ beforeUnmount() {
+ // Stop local-URL probing timers, listeners and any in-flight probe
+ this.stopLocalUrlChecks();
+ },
};
diff --git a/src/utils/config/ConfigSchema.json b/src/utils/config/ConfigSchema.json
index 514cac2c..92def4ed 100644
--- a/src/utils/config/ConfigSchema.json
+++ b/src/utils/config/ConfigSchema.json
@@ -1058,19 +1058,19 @@
"localUrl": {
"title": "Local URL",
"type": "string",
- "description": "Optional alternative URL preferred when it is reachable from your browser (e.g. a LAN address). On load Dashy probes this URL; if it responds, clicking the item opens it, otherwise it falls back to the Service URL. Useful for local-vs-remote access (Tailscale, VPN, etc)"
+ "description": "Optional alternative URL preferred when it is reachable from your browser (e.g. a LAN address)"
},
"localUrlTimeout": {
"title": "Local URL Probe Timeout",
"type": "number",
"default": 1500,
- "description": "Milliseconds to wait for the Local URL reachability probe before giving up and using the Service URL. Clamped between 300 and 5000. The probe runs in the background, so it never delays clicks"
+ "description": "For local URLs, ms to wait for the Local URL reachability probe before falling back to normal URL"
},
"localUrlCheckInterval": {
"title": "Local URL Re-check Interval",
"type": "number",
"default": 0,
- "description": "Seconds between background re-checks of the Local URL. 0 = only check on page load and when the tab regains focus. Clamped to 300 max"
+ "description": "For local URLs, seconds between background re-checks of the Local URL. 0 = only check on page load"
},
"displayData": {
"title": "Display Data",