plugins/kolab_tags

Aleksander Machniak machniak at kolabsys.com
Thu Mar 5 14:27:36 CET 2015


 plugins/kolab_tags/kolab_tags.js             |   18 ++++++------------
 plugins/kolab_tags/lib/kolab_tags_engine.php |    4 ++++
 2 files changed, 10 insertions(+), 12 deletions(-)

New commits:
commit bf648058822662e5c3a0e8b05670af095fbb2011
Author: Aleksander Machniak <machniak at kolabsys.com>
Date:   Thu Mar 5 07:59:12 2015 -0500

    Remove race-condition when removing tags from email (#4771)
    
    Sometimes (using Firefox 24) removing the tag didn't work.

diff --git a/plugins/kolab_tags/kolab_tags.js b/plugins/kolab_tags/kolab_tags.js
index 329c18e..2e68e92 100644
--- a/plugins/kolab_tags/kolab_tags.js
+++ b/plugins/kolab_tags/kolab_tags.js
@@ -350,7 +350,7 @@ function update_tags(response)
     tag_selector_reset();
 
     // remove deleted tags
-    remove_tags(response['delete']);
+    remove_tags(response['delete'], response.mark);
 
     // add new tags
     $.each(response.add || [], function() {
@@ -423,8 +423,7 @@ function remove_tags(tags, selection)
     $.each(tags, function() {
         var i, id = this,
             filter = function() { return $(this).data('tag') == id; },
-            elements = tagboxes.filter(filter),
-            selected = $.inArray(String(id), tagsfilter);
+            elements = tagboxes.filter(filter);
 
         // ... from the messages list (or message page)
         elements.remove();
@@ -448,8 +447,7 @@ function remove_tags(tags, selection)
         }
 
         // if tagged messages found and tag was selected - refresh the list
-        if (selected > -1) {
-            tagsfilter.splice(selected, 1);
+        if (!update_filter && $.inArray(String(id), tagsfilter) > -1) {
             update_filter = true;
         }
     });
@@ -549,17 +547,13 @@ function tag_remove(props, obj, event)
     }
 
     var postdata = rcmail.selection_post_data(),
-        tags = props != '*' ? [props] : $.map(rcmail.env.tags, function(tag) { return tag.uid; })
-        win = window.parent && parent.rcmail && parent.remove_tags ? parent : window;
+        tags = props != '*' ? [props] : $.map(rcmail.env.tags, function(tag) { return tag.uid; }),
+        rc = window.parent && parent.rcmail && parent.remove_tags ? parent.rcmail : rcmail;
 
     postdata._tag = props;
     postdata._act = 'remove';
 
-    rcmail.http_post('plugin.kolab_tags', postdata, true);
-
-    // remove tags from message(s) without waiting to a response
-    // in case of an error the list will be refreshed
-    win.remove_tags(tags, true);
+    rc.http_post('plugin.kolab_tags', postdata, true);
 }
 
 // executes messages search according to selected messages
diff --git a/plugins/kolab_tags/lib/kolab_tags_engine.php b/plugins/kolab_tags/lib/kolab_tags_engine.php
index 14a6e07..201b23a 100644
--- a/plugins/kolab_tags/lib/kolab_tags_engine.php
+++ b/plugins/kolab_tags/lib/kolab_tags_engine.php
@@ -132,6 +132,7 @@ class kolab_tags_engine
         $filter  = $tag == '*' ? array() : array(array('uid', '=', explode(',', $tag)));
         $taglist = $this->backend->list_tags($filter);
         $filter  = array();
+        $tags    = array();
 
         foreach (rcmail::get_uids() as $mbox => $uids) {
             if ($uids === '*') {
@@ -181,6 +182,8 @@ class kolab_tags_engine
                     $error = true;
                 }
             }
+
+            $tags[] = $tag['uid'];
         }
 
         if ($error) {
@@ -191,6 +194,7 @@ class kolab_tags_engine
         }
         else {
             $this->rc->output->show_message($this->plugin->gettext('untaggingsuccess'), 'confirmation');
+            $this->rc->output->command('plugin.kolab_tags', array('mark' => 1, 'delete' => $tags));
         }
     }
 




More information about the commits mailing list