fjordgard

A desktop clock application
Log | Files | Refs | README | LICENSE

commit 9310680f597d0c2b8814be3209d88fac7d92aca5
parent bf02d44809ee26665c2014885daaaf48b4c0229f
Author: Sylvia Ivory <git@sivory.net>
Date:   Fri, 20 Jun 2025 02:54:33 -0700

Allow links to open on web

Diffstat:
Msrc/background.rs | 13+++++++++----
Msrc/icon.rs | 3++-
Msrc/main.rs | 7++-----
3 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/src/background.rs b/src/background.rs @@ -277,15 +277,20 @@ impl BackgroundHandle { Task::none() } } + #[cfg(not(target_arch = "wasm32"))] Message::OpenUrl(url) => { - #[cfg(not(target_arch = "wasm32"))] if let Err(e) = open::that_detached(url) { error!("failed to open link: {e}") } - #[cfg(target_arch = "wasm32")] - { - error!("open not implemented, {url}"); + Task::none() + } + #[cfg(target_arch = "wasm32")] + Message::OpenUrl(url) => { + if let Some(window) = web_sys::window() { + if window.open_with_url(&url).is_err() { + error!("failed to open link") + } } Task::none() diff --git a/src/icon.rs b/src/icon.rs @@ -1,5 +1,6 @@ use iced::{ - widget::{button, svg, Svg}, Color, Element, Length, Theme + Color, Element, Length, Theme, + widget::{Svg, button, svg}, }; use rust_embed::Embed; diff --git a/src/main.rs b/src/main.rs @@ -422,11 +422,8 @@ impl Fjordgard { icon(&self.forecast_icon) .height(Length::Fixed(32.0)) .width(Length::Fixed(32.0)), - horizontal_space() - .width(Length::Fixed(7.25)), - text(&self.forecast_text) - .color(Color::WHITE) - .size(25) + horizontal_space().width(Length::Fixed(7.25)), + text(&self.forecast_text).color(Color::WHITE).size(25) ]) .center_x(Length::Fill);