fix: clear image on device as well as in the UI when clearing the canvas due to the slot becoming empty in case another render occurred since the device was cleared on profile switch

This commit is contained in:
nekename committed 2026-02-28 15:51:32 +00:00
1 parent 231e3dc3d6
commit 4663a4961d
2 files changed
+5 -4

No files matched your search

+2 -2
View File
@@ -217,12 +217,12 @@ pub async fn set_state(instance: ActionInstance, state: u16) -> Result<(), Error
}
#[command]
pub async fn update_image(context: Context, image: String) {
pub async fn update_image(context: Context, image: Option<String>) {
if Some(&context.profile) != crate::store::profiles::DEVICE_STORES.write().await.get_selected_profile(&context.device).ok().as_ref() {
return;
}
if let Err(error) = crate::events::outbound::devices::update_image(context, Some(image)).await {
if let Err(error) = crate::events::outbound::devices::update_image(context, image).await {
log::warn!("Failed to update device image: {}", error);
}
}
+3 -2
View File
@@ -112,8 +112,9 @@
if (!sl) {
const unlock = await lock.lock();
try {
const context = canvas?.getContext("2d");
if (context) context.clearRect(0, 0, canvas.width, canvas.height);
const ctx = canvas?.getContext("2d");
if (ctx) ctx.clearRect(0, 0, canvas.width, canvas.height);
if (active) await invoke("update_image", { context, image: null });
} finally {
unlock();
}