override LibItem props on AddToLibrary if item exist
@@ -114,9 +114,14 @@ impl LibraryLoadable {
}
}
ActionUser::AddToLibrary { meta_item, now } => {
- let mut lib_item = match lib_bucket.items.get(&meta_item.id) {
- Some(lib_item) => lib_item.to_owned(),
- None => LibItem {
+ let ctime = match lib_bucket.items.get(&meta_item.id) {
+ Some(lib_item) => match &lib_item.ctime {
+ Some(ctime) => ctime,
+ _ => now,
+ },
+ _ => now,
+ };
+ let lib_item = LibItem {
id: meta_item.id.to_owned(),
type_name: meta_item.type_name.to_owned(),
name: meta_item.name.to_owned(),
@@ -131,15 +136,12 @@ impl LibraryLoadable {
} else {
None
},
- ctime: Some(now.to_owned()),
+ ctime: Some(ctime.to_owned()),
mtime: now.to_owned(),
removed: false,
temp: false,
state: LibItemState::default(),
- },
};
- lib_item.removed = false;
- lib_item.mtime = now.to_owned();
self.update::<Env>(
&content,
&Msg::Action(Action::UserOp(ActionUser::LibUpdate(lib_item))),
