adds reactivity when undoing an event

This commit is contained in:
2019-10-28 16:08:05 +01:00
parent 8d1344e0b6
commit 1f2a940968
5 changed files with 39 additions and 29 deletions

View File

@@ -198,9 +198,14 @@ pub fn execute(
None
}
ApiActions::UndoLastAction(id) => {
match db::undo_last_action(conn, id) {
Ok(ev) => response.notify(format!("'{}' annulé(e)", ev.name())),
Err(e) => response.push_error(format!("Erreur : {:?}", e)),
if let Ok(event) = db::models::history::get_last_of_player(conn, id) {
let name = String::from(event.name());
for undone in event.undo(conn)?.into_inner().into_iter() {
response.push_update(undone);
}
response.notify(format!("'{}' annulé(e)", name));
} else {
response.push_error("Aucune action trouvée")
};
None
}