Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into andreas/video-aggress…
Browse files Browse the repository at this point in the history
…ive-enqueueing
  • Loading branch information
Wumpf committed Jan 31, 2025
2 parents 455c65c + 026d846 commit 5a2db64
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
21 changes: 15 additions & 6 deletions crates/viewer/re_viewer/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,9 @@ impl App {

#[cfg(target_arch = "wasm32")]
UICommand::CopyDirectLink => {
self.run_copy_direct_link_command(store_context);
if self.run_copy_direct_link_command(store_context).is_none() {
re_log::error!("Failed to copy direct link to clipboard. Is this not running in a browser?");
}
}

#[cfg(target_arch = "wasm32")]
Expand Down Expand Up @@ -1018,11 +1020,16 @@ impl App {
}

#[cfg(target_arch = "wasm32")]
fn run_copy_direct_link_command(&mut self, store_context: Option<&StoreContext<'_>>) {
let location = web_sys::window().unwrap().location();
let origin = location.origin().unwrap();
let host = location.host().unwrap();
let pathname = location.pathname().unwrap();
fn run_copy_direct_link_command(
&mut self,
store_context: Option<&StoreContext<'_>>,
) -> Option<()> {
use crate::web_tools::JsResultExt as _;

let location = web_sys::window()?.location();
let origin = location.origin().ok_or_log_js_error_once()?;
let host = location.host().ok_or_log_js_error_once()?;
let pathname = location.pathname().ok_or_log_js_error_once()?;

let hosted_viewer_path = if self.build_info.is_final() {
// final release, use version tag
Expand Down Expand Up @@ -1052,6 +1059,8 @@ impl App {
self.egui_ctx.copy_text(direct_link.clone());
self.notifications
.success(format!("Copied {direct_link:?} to clipboard"));

Some(())
}

fn memory_panel_ui(
Expand Down
8 changes: 7 additions & 1 deletion crates/viewer/re_viewer/src/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ impl WebHandle {

let canvas = if let Some(canvas_id) = canvas.as_string() {
// For backwards compatibility with old JS/HTML written before 2024-08-30
let document = web_sys::window().unwrap().document().unwrap();
let document = web_sys::window()
.ok_or_else(|| "Failed to get window. Are we not in a browser?".to_owned())?
.document()
.ok_or_else(|| {
"Failed to get window.document. Are we not in a browser?".to_owned()
})?;
let element = document
.get_element_by_id(&canvas_id)
.ok_or_else(|| format!("Canvas element '{canvas_id}' not found."))?;
Expand Down Expand Up @@ -729,6 +734,7 @@ fn create_app(
/// by rerun employees manually in `app.rerun.io`.
#[cfg(feature = "analytics")]
#[wasm_bindgen]
#[allow(clippy::unwrap_used)] // This is only run by rerun employees, so it's fine to panic
pub fn set_email(email: String) {
let mut config = re_analytics::Config::load().unwrap().unwrap_or_default();
config.opt_in_metadata.insert("email".into(), email.into());
Expand Down

0 comments on commit 5a2db64

Please sign in to comment.