Only modify NewTransferState by reduce_mut
This commit is contained in:
parent
1b0be78e85
commit
6e8c1eff55
|
@ -1,6 +1,7 @@
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
use yew::prelude::*;
|
use yew::prelude::*;
|
||||||
use yewdux::prelude::*;
|
use yewdux::prelude::*;
|
||||||
|
use std::intrinsics::discriminant_value;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use super::super::states::NewTransferState;
|
use super::super::states::NewTransferState;
|
||||||
|
@ -36,7 +37,6 @@ pub fn DestinationPlate(props: &DestinationPlateProps) -> Html {
|
||||||
};
|
};
|
||||||
let dispatch = Dispatch::<NewTransferState>::subscribe(menu_sync_callback);
|
let dispatch = Dispatch::<NewTransferState>::subscribe(menu_sync_callback);
|
||||||
|
|
||||||
|
|
||||||
let mouse_callback = {
|
let mouse_callback = {
|
||||||
let m_start_handle = m_start_handle.clone();
|
let m_start_handle = m_start_handle.clone();
|
||||||
let m_end_handle = m_end_handle.clone();
|
let m_end_handle = m_end_handle.clone();
|
||||||
|
@ -69,13 +69,9 @@ pub fn DestinationPlate(props: &DestinationPlateProps) -> Html {
|
||||||
if let Some(ul) = *m_start_handle {
|
if let Some(ul) = *m_start_handle {
|
||||||
if let Some(br) = *m_end_handle {
|
if let Some(br) = *m_end_handle {
|
||||||
if let Ok(rd) = RegionDisplay::try_from((ul.0, ul.1, br.0, br.1)) {
|
if let Ok(rd) = RegionDisplay::try_from((ul.0, ul.1, br.0, br.1)) {
|
||||||
dispatch.set(NewTransferState {
|
dispatch.reduce_mut(|state| {
|
||||||
source_id: current.source_id,
|
state.destination_region = rd;
|
||||||
destination_id: current.destination_id,
|
});
|
||||||
source_region: current.source_region.clone(),
|
|
||||||
destination_region: rd,
|
|
||||||
interleave_x: current.interleave_x,
|
|
||||||
interleave_y: current.interleave_y })
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,18 +64,13 @@ pub fn SourcePlate(props: &SourcePlateProps) -> Html {
|
||||||
let m_stat_handle = m_stat_handle.clone();
|
let m_stat_handle = m_stat_handle.clone();
|
||||||
|
|
||||||
Callback::from(move |_: MouseEvent| {
|
Callback::from(move |_: MouseEvent| {
|
||||||
let current = dispatch.get();
|
|
||||||
m_stat_handle.set(false);
|
m_stat_handle.set(false);
|
||||||
if let Some(ul) = *m_start_handle {
|
if let Some(ul) = *m_start_handle {
|
||||||
if let Some(br) = *m_end_handle {
|
if let Some(br) = *m_end_handle {
|
||||||
if let Ok(rd) = RegionDisplay::try_from((ul.0, ul.1, br.0, br.1)) {
|
if let Ok(rd) = RegionDisplay::try_from((ul.0, ul.1, br.0, br.1)) {
|
||||||
dispatch.set(NewTransferState {
|
dispatch.reduce_mut(|state| {
|
||||||
source_id: current.source_id,
|
state.source_region = rd;
|
||||||
destination_id: current.destination_id,
|
});
|
||||||
source_region: rd,
|
|
||||||
destination_region: current.destination_region.clone(),
|
|
||||||
interleave_x: current.interleave_x,
|
|
||||||
interleave_y: current.interleave_y })
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,13 +24,8 @@ pub fn TransferMenu() -> Html {
|
||||||
let input = target.and_then(|t| t.dyn_into::<HtmlInputElement>().ok());
|
let input = target.and_then(|t| t.dyn_into::<HtmlInputElement>().ok());
|
||||||
if let Some(input) = input {
|
if let Some(input) = input {
|
||||||
if let Ok(rd) = RegionDisplay::try_from(input.value()) {
|
if let Ok(rd) = RegionDisplay::try_from(input.value()) {
|
||||||
dispatch.set( NewTransferState {
|
dispatch.reduce_mut(|state| {
|
||||||
source_id: state.source_id,
|
state.source_region = rd;
|
||||||
destination_id: state.destination_id,
|
|
||||||
source_region: rd,
|
|
||||||
destination_region: state.destination_region.clone(),
|
|
||||||
interleave_x: state.interleave_x,
|
|
||||||
interleave_y: state.interleave_y
|
|
||||||
});
|
});
|
||||||
input.set_custom_validity("");
|
input.set_custom_validity("");
|
||||||
} else {
|
} else {
|
||||||
|
@ -49,13 +44,8 @@ pub fn TransferMenu() -> Html {
|
||||||
let input = target.and_then(|t| t.dyn_into::<HtmlInputElement>().ok());
|
let input = target.and_then(|t| t.dyn_into::<HtmlInputElement>().ok());
|
||||||
if let Some(input) = input {
|
if let Some(input) = input {
|
||||||
if let Ok(rd) = RegionDisplay::try_from(input.value()) {
|
if let Ok(rd) = RegionDisplay::try_from(input.value()) {
|
||||||
dispatch.set( NewTransferState {
|
dispatch.reduce_mut(|state| {
|
||||||
source_id: state.source_id,
|
state.destination_region = rd;
|
||||||
destination_id: state.destination_id,
|
|
||||||
source_region: state.source_region.clone(),
|
|
||||||
destination_region: rd,
|
|
||||||
interleave_x: state.interleave_x,
|
|
||||||
interleave_y: state.interleave_y
|
|
||||||
});
|
});
|
||||||
input.set_custom_validity("");
|
input.set_custom_validity("");
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue