mirror of
https://github.com/nekename/OpenDeck.git
synced 2026-10-28 09:44:01 +00:00
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:
2 files changed
+5
-4
No files matched your search
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user