Remove race-condition when removing tags from email (#4771)
Sometimes (using Firefox 24) removing the tag didn't work.
This commit is contained in:
parent
a5c9c026e2
commit
bf64805882
2 changed files with 10 additions and 12 deletions
|
@ -350,7 +350,7 @@ function update_tags(response)
|
||||||
tag_selector_reset();
|
tag_selector_reset();
|
||||||
|
|
||||||
// remove deleted tags
|
// remove deleted tags
|
||||||
remove_tags(response['delete']);
|
remove_tags(response['delete'], response.mark);
|
||||||
|
|
||||||
// add new tags
|
// add new tags
|
||||||
$.each(response.add || [], function() {
|
$.each(response.add || [], function() {
|
||||||
|
@ -423,8 +423,7 @@ function remove_tags(tags, selection)
|
||||||
$.each(tags, function() {
|
$.each(tags, function() {
|
||||||
var i, id = this,
|
var i, id = this,
|
||||||
filter = function() { return $(this).data('tag') == id; },
|
filter = function() { return $(this).data('tag') == id; },
|
||||||
elements = tagboxes.filter(filter),
|
elements = tagboxes.filter(filter);
|
||||||
selected = $.inArray(String(id), tagsfilter);
|
|
||||||
|
|
||||||
// ... from the messages list (or message page)
|
// ... from the messages list (or message page)
|
||||||
elements.remove();
|
elements.remove();
|
||||||
|
@ -448,8 +447,7 @@ function remove_tags(tags, selection)
|
||||||
}
|
}
|
||||||
|
|
||||||
// if tagged messages found and tag was selected - refresh the list
|
// if tagged messages found and tag was selected - refresh the list
|
||||||
if (selected > -1) {
|
if (!update_filter && $.inArray(String(id), tagsfilter) > -1) {
|
||||||
tagsfilter.splice(selected, 1);
|
|
||||||
update_filter = true;
|
update_filter = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -549,17 +547,13 @@ function tag_remove(props, obj, event)
|
||||||
}
|
}
|
||||||
|
|
||||||
var postdata = rcmail.selection_post_data(),
|
var postdata = rcmail.selection_post_data(),
|
||||||
tags = props != '*' ? [props] : $.map(rcmail.env.tags, function(tag) { return tag.uid; })
|
tags = props != '*' ? [props] : $.map(rcmail.env.tags, function(tag) { return tag.uid; }),
|
||||||
win = window.parent && parent.rcmail && parent.remove_tags ? parent : window;
|
rc = window.parent && parent.rcmail && parent.remove_tags ? parent.rcmail : rcmail;
|
||||||
|
|
||||||
postdata._tag = props;
|
postdata._tag = props;
|
||||||
postdata._act = 'remove';
|
postdata._act = 'remove';
|
||||||
|
|
||||||
rcmail.http_post('plugin.kolab_tags', postdata, true);
|
rc.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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// executes messages search according to selected messages
|
// executes messages search according to selected messages
|
||||||
|
|
|
@ -132,6 +132,7 @@ class kolab_tags_engine
|
||||||
$filter = $tag == '*' ? array() : array(array('uid', '=', explode(',', $tag)));
|
$filter = $tag == '*' ? array() : array(array('uid', '=', explode(',', $tag)));
|
||||||
$taglist = $this->backend->list_tags($filter);
|
$taglist = $this->backend->list_tags($filter);
|
||||||
$filter = array();
|
$filter = array();
|
||||||
|
$tags = array();
|
||||||
|
|
||||||
foreach (rcmail::get_uids() as $mbox => $uids) {
|
foreach (rcmail::get_uids() as $mbox => $uids) {
|
||||||
if ($uids === '*') {
|
if ($uids === '*') {
|
||||||
|
@ -181,6 +182,8 @@ class kolab_tags_engine
|
||||||
$error = true;
|
$error = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$tags[] = $tag['uid'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($error) {
|
if ($error) {
|
||||||
|
@ -191,6 +194,7 @@ class kolab_tags_engine
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$this->rc->output->show_message($this->plugin->gettext('untaggingsuccess'), 'confirmation');
|
$this->rc->output->show_message($this->plugin->gettext('untaggingsuccess'), 'confirmation');
|
||||||
|
$this->rc->output->command('plugin.kolab_tags', array('mark' => 1, 'delete' => $tags));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue