diff --git a/src/io/recovery.rs b/src/io/recovery.rs index ad94baa01..d8a779b5e 100644 --- a/src/io/recovery.rs +++ b/src/io/recovery.rs @@ -589,6 +589,7 @@ fn diagnostic_platform() -> String { format!("{}/{}", std::env::consts::OS, std::env::consts::ARCH) } +#[cfg(not(target_arch = "wasm32"))] fn unix_seconds() -> u64 { std::time::SystemTime::now() .duration_since(std::time::UNIX_EPOCH) @@ -596,6 +597,11 @@ fn unix_seconds() -> u64 { .unwrap_or(0) } +#[cfg(target_arch = "wasm32")] +fn unix_seconds() -> u64 { + (js_sys::Date::now() / 1000.0) as u64 +} + fn safe_stem(value: &str) -> String { let filtered: String = value .chars() @@ -672,3 +678,41 @@ fn write_unique(directory: &Path, file_name: &str, body: &str) -> Result 0); + assert_eq!( + report.report_id, + report_id(report.source_sha256.as_deref(), report.created_unix_seconds) + ); + } +}