From 974f3f30709bb72d67f2699eb429de5d1cfbea57 Mon Sep 17 00:00:00 2001 From: Abdelrahman Ashraf Date: Mon, 24 Jun 2024 16:29:05 +0700 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=F0=9F=90=9B=20manifest=5Fstring()?= =?UTF-8?q?=20panics=20when=20no=20manifest=20available?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dotlottie-rs/src/dotlottie_player.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dotlottie-rs/src/dotlottie_player.rs b/dotlottie-rs/src/dotlottie_player.rs index b2b43dde..e49e4974 100644 --- a/dotlottie-rs/src/dotlottie_player.rs +++ b/dotlottie-rs/src/dotlottie_player.rs @@ -1145,8 +1145,10 @@ impl DotLottiePlayerContainer { } pub fn manifest_string(&self) -> String { - self.runtime.read().unwrap().manifest().unwrap().to_string() - } + self.runtime.try_read().ok() + .and_then(|runtime| runtime.manifest()) + .map_or_else(String::new, |manifest| manifest.to_string()) + } pub fn is_complete(&self) -> bool { self.runtime.read().unwrap().is_complete() @@ -1751,8 +1753,9 @@ impl DotLottiePlayer { true } + #[cfg(target_arch = "wasm32")] pub fn manifest_string(&self) -> String { - self.player.read().unwrap().manifest_string() + self.player.try_read().map_or_else(|_| String::new(), |player| player.manifest_string()) } pub fn is_complete(&self) -> bool { From 5ce692ef996809be403d9bb7058e882ace02dbe8 Mon Sep 17 00:00:00 2001 From: Abdelrahman Ashraf Date: Mon, 24 Jun 2024 17:35:59 +0700 Subject: [PATCH 2/2] =?UTF-8?q?chore:=20=F0=9F=A4=96=20fix=20failing=20tes?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dotlottie-rs/src/dotlottie_player.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/dotlottie-rs/src/dotlottie_player.rs b/dotlottie-rs/src/dotlottie_player.rs index e49e4974..dca031bc 100644 --- a/dotlottie-rs/src/dotlottie_player.rs +++ b/dotlottie-rs/src/dotlottie_player.rs @@ -1753,7 +1753,6 @@ impl DotLottiePlayer { true } - #[cfg(target_arch = "wasm32")] pub fn manifest_string(&self) -> String { self.player.try_read().map_or_else(|_| String::new(), |player| player.manifest_string()) }