]> uap-core.de Git - note.git/commitdiff
add check to open_extern if the task is already running in the background main
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Thu, 16 Jul 2026 16:42:35 +0000 (18:42 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Thu, 16 Jul 2026 16:42:35 +0000 (18:42 +0200)
application/note/src/file.rs

index f5622c2ad0c49e5baaadbf92ac691d0c976c8667..560c2c195f0569d212519dd5034acae70b00e28c 100644 (file)
@@ -44,6 +44,7 @@ pub struct FileNote {
 
     pub local_path: Option<String>,
     pub is_tmp_file: bool,
+    pub is_opening: bool,
 
     #[bind("note_type")]
     pub note_type: UiInteger,
@@ -65,6 +66,7 @@ impl FileNote {
             nodename: String::default(),
             local_path: None,
             is_tmp_file: false,
+            is_opening: false,
 
             note_type: Default::default(),
             note_nodename: Default::default(),
@@ -83,6 +85,10 @@ impl FileNote {
 
     #[action]
     pub fn open_extern(&mut self, _event: &ActionEvent) {
+        if self.is_opening {
+            return;
+        }
+
         let Some(doc) = self.doc.get_doc() else {
             return;
         };
@@ -91,9 +97,11 @@ impl FileNote {
             println!("open file: {}", path);
             open_file(path.as_str());
         } else if let NoteId::Id(note_id) = self.id {
+            self.is_opening = true;
             let proxy = doc.doc_proxy();
             self.backend.open_extern(note_id, |result|{
                 proxy.call_mainthread(move |_doc, note|{
+                    note.is_opening = false;
                     match result {
                         OpenExternResult::Ok((path, istmp)) => {
                             println!("open file: {}", path);