fix: Fix panic when select priority
This commit is contained in:
@@ -262,14 +262,17 @@ impl TaskDetailModal {
|
|||||||
Dropdown::new("task-edit-status")
|
Dropdown::new("task-edit-status")
|
||||||
.items(status_items)
|
.items(status_items)
|
||||||
.on_select(Arc::new(move |index, _item, cx| {
|
.on_select(Arc::new(move |index, _item, cx| {
|
||||||
cx.update_entity(&modal_entity, |modal, cx| {
|
let modal_entity = modal_entity.clone();
|
||||||
modal.state.form.status = match index {
|
cx.defer(move |cx| {
|
||||||
0 => task::TaskStatus::Pending,
|
let _ = modal_entity.update(cx, |modal, cx| {
|
||||||
1 => task::TaskStatus::Completed,
|
modal.state.form.status = match index {
|
||||||
2 => task::TaskStatus::Deleted,
|
0 => task::TaskStatus::Pending,
|
||||||
_ => task::TaskStatus::Pending,
|
1 => task::TaskStatus::Completed,
|
||||||
};
|
2 => task::TaskStatus::Deleted,
|
||||||
cx.notify();
|
_ => task::TaskStatus::Pending,
|
||||||
|
};
|
||||||
|
cx.notify();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
@@ -287,15 +290,18 @@ impl TaskDetailModal {
|
|||||||
Dropdown::new("task-edit-priority")
|
Dropdown::new("task-edit-priority")
|
||||||
.items(priority_items)
|
.items(priority_items)
|
||||||
.on_select(Arc::new(move |index, _item, cx| {
|
.on_select(Arc::new(move |index, _item, cx| {
|
||||||
cx.update_entity(&modal_entity, |modal, cx| {
|
let modal_entity = modal_entity.clone();
|
||||||
modal.state.form.priority = match index {
|
cx.defer(move |cx| {
|
||||||
0 => task::TaskPriority::High,
|
let _ = modal_entity.update(cx, |modal, cx| {
|
||||||
1 => task::TaskPriority::Medium,
|
modal.state.form.priority = match index {
|
||||||
2 => task::TaskPriority::Low,
|
0 => task::TaskPriority::High,
|
||||||
3 => task::TaskPriority::None,
|
1 => task::TaskPriority::Medium,
|
||||||
_ => task::TaskPriority::None,
|
2 => task::TaskPriority::Low,
|
||||||
};
|
3 => task::TaskPriority::None,
|
||||||
cx.notify();
|
_ => task::TaskPriority::None,
|
||||||
|
};
|
||||||
|
cx.notify();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user