From 6cfa686b5585f43321cb68b12f0746d9d95ba457 Mon Sep 17 00:00:00 2001 From: Emilia Date: Tue, 13 Feb 2024 22:06:55 -0500 Subject: [PATCH] fix: not switching on plate type me when i migrate correctly the first time and have no lingering bugs --- plate-tool-web/src/components/plates/plate.rs | 2 +- plate-tool-web/src/components/plates/plate_callbacks.rs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/plate-tool-web/src/components/plates/plate.rs b/plate-tool-web/src/components/plates/plate.rs index 938e963..e761007 100644 --- a/plate-tool-web/src/components/plates/plate.rs +++ b/plate-tool-web/src/components/plates/plate.rs @@ -83,7 +83,7 @@ pub fn Plate(props: &PlateProps) -> Html { let mouseup_callback = { let m_start_handle = m_start_handle.clone(); let m_end_handle = m_end_handle.clone(); - plate_callbacks::mouseup_callback(m_start_handle, m_end_handle, m_stat_handle, ct_dispatch) + plate_callbacks::mouseup_callback(m_start_handle, m_end_handle, m_stat_handle, ct_dispatch, props.ptype) }; let mouseleave_callback = Callback::clone(&mouseup_callback); diff --git a/plate-tool-web/src/components/plates/plate_callbacks.rs b/plate-tool-web/src/components/plates/plate_callbacks.rs index 089fcbf..9579c64 100644 --- a/plate-tool-web/src/components/plates/plate_callbacks.rs +++ b/plate-tool-web/src/components/plates/plate_callbacks.rs @@ -3,6 +3,7 @@ use yewdux::prelude::*; use crate::components::states::CurrentTransfer; use plate_tool_lib::transfer_region::Region; +use plate_tool_lib::plate::PlateType; // Color Palette for the Source Plates, can be changed here @@ -34,6 +35,7 @@ pub fn mouseup_callback( m_end_handle: MEndHandle, m_stat_handle: MStatHandle, ct_dispatch: Dispatch, + ptype: PlateType, ) -> Callback { Callback::from(move |_: MouseEvent| { m_stat_handle.set(false); @@ -41,7 +43,10 @@ pub fn mouseup_callback( if let Some(br) = *m_end_handle { if let Ok(rd) = RegionDisplay::try_from((ul.0, ul.1, br.0, br.1)) { ct_dispatch.reduce_mut(|state| { - state.transfer.transfer_region.source_region = Region::from(&rd); + match ptype { + PlateType::Source => state.transfer.transfer_region.source_region = Region::from(&rd), + PlateType::Destination => state.transfer.transfer_region.dest_region = Region::from(&rd) + }; }); } }