Skip to content

Commit

Permalink
Add instance in save fn
Browse files Browse the repository at this point in the history
  • Loading branch information
RedstoneWizard08 committed Mar 21, 2023
1 parent cd5f23a commit 4cf6dc5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions common/src/instances/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,20 @@ impl Instance {

pub fn save(&self) {
let mut instances = Instance::load();
let mut found = false;

for (index, instance) in instances.clone().iter().enumerate() {
if instance.id == self.id {
let _ = replace(&mut instances[index], self.clone());

found = true;
}
}

if !found {
instances.push(self.clone());
}

Instance::save_all(&instances);
}

Expand Down

0 comments on commit 4cf6dc5

Please sign in to comment.