| ... | @@ -736,7 +736,7 @@ impl State { | ... | @@ -736,7 +736,7 @@ impl State { |
| 736 | self.title(); | 736 | self.title(); |
| 737 | } | 737 | } |
| 738 | self.folder_rename = Some((library.location.clone(), to.clone())); | 738 | self.folder_rename = Some((library.location.clone(), to.clone())); |
| 739 | let (cache, proxy) = (self.cache.clone(), self.proxy.clone()); | 739 | let (cache, proxy, requested) = (self.cache.clone(), self.proxy.clone(), self.loading); |
| 740 | crate::spawn_async(move || async move { | 740 | crate::spawn_async(move || async move { |
| 741 | let structure = Arc::clone(&library.structure); | 741 | let structure = Arc::clone(&library.structure); |
| 742 | let _structure = structure.lock().await; | 742 | let _structure = structure.lock().await; |
| ... | @@ -773,7 +773,20 @@ impl State { | ... | @@ -773,7 +773,20 @@ impl State { |
| 773 | } | 773 | } |
| 774 | let reopened = Arc::new(reopened); | 774 | let reopened = Arc::new(reopened); |
| 775 | let _ = proxy.send_event(crate::UserEvent::Then(Box::new(move |state| { | 775 | let _ = proxy.send_event(crate::UserEvent::Then(Box::new(move |state| { |
| 776 | state.renamed_notebook(&library, reopened, showing.then_some(shown)); | 776 | if state |
| | 777 | .folder_rename |
| | 778 | .as_ref() |
| | 779 | .is_some_and(|(from, target)| from == &library.location && target == &to) |
| | 780 | { |
| | 781 | state.folder_rename = None; |
| | 782 | } |
| | 783 | let restore = showing |
| | 784 | && requested == state.loading |
| | 785 | && state.notebook().is_some_and(|current| { |
| | 786 | current.location == library.location |
| | 787 | && Arc::ptr_eq(&current.structure, &library.structure) |
| | 788 | }); |
| | 789 | state.renamed_notebook(&library, reopened, restore.then_some(shown)); |
| 777 | if let Some(problem) = problem { | 790 | if let Some(problem) = problem { |
| 778 | platform::alert("Couldn't rename the folder", &problem); | 791 | platform::alert("Couldn't rename the folder", &problem); |
| 779 | } | 792 | } |
| ... | @@ -791,7 +804,6 @@ impl State { | ... | @@ -791,7 +804,6 @@ impl State { |
| 791 | reopened: Arc<Library>, | 804 | reopened: Arc<Library>, |
| 792 | shown: Option<Option<String>>, | 805 | shown: Option<Option<String>>, |
| 793 | ) { | 806 | ) { |
| 794 | self.folder_rename = None; | | |
| 795 | let (from, to) = (old.location.clone(), reopened.location.clone()); | 807 | let (from, to) = (old.location.clone(), reopened.location.clone()); |
| 796 | match (self.notebooks.iter_mut()).find(|open| Arc::ptr_eq(open, old)) { | 808 | match (self.notebooks.iter_mut()).find(|open| Arc::ptr_eq(open, old)) { |
| 797 | Some(open) => *open = Arc::clone(&reopened), | 809 | Some(open) => *open = Arc::clone(&reopened), |