Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion js/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -3802,7 +3802,14 @@ var ImpBase = {
opts.vs = this._getSelection(opts);

if (this._doMsgAction('deleteMessages', opts, {})) {
this.updateFlag(opts.vs, ImpCore.conf.FLAG_DELETED, true);
/* When using a Trash mailbox (nodeleteshow), messages are moved
* or hidden — they must not be painted as IMAP \Deleted. That
* optimistic mark is only correct for classic mark-for-deletion
* mode, and in search views it often sticks even after a successful
* move-to-trash. Rely on the server disappear/viewport refresh. */
if (!this.viewport.getMetaData('nodeleteshow')) {
this.updateFlag(opts.vs, ImpCore.conf.FLAG_DELETED, true);
}
}
},

Expand Down
8 changes: 8 additions & 0 deletions lib/Ajax/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,14 @@ public function deleteMsgs(IMP_Indices $indices, $changed, $force = false)
$changed = ($this->indices->mailbox->getSort()->sortby == Horde_Imap_Client::SORT_THREAD);
}

/* Search BUIDs are session-synthetic and the result set is rebuilt
* after mailbox mutations. Always refresh the viewport so moved/
* deleted messages leave the search list instead of lingering with
* an optimistic \Deleted appearance. */
if (!$changed && $this->indices->mailbox->search) {
$changed = true;
}

if ($changed) {
$this->addTask('viewport', $this->viewPortData(true));
} elseif (($indices instanceof IMP_Indices_Mailbox)
Expand Down
61 changes: 32 additions & 29 deletions lib/Indices.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,46 +444,49 @@ public function delete(array $opts = [])
$imp_imap = $ob->mbox->imp_imap;
$ids_ob = $imp_imap->getIdsOb($ob->uids);
$processed = false;
$moved_to_trash = false;

/* Trash is only valid for IMAP mailboxes. */
if ($use_trash_mbox
&& ($ob->mbox != $trash)
/* TODO(?): Don't use Trash mailbox for remote accounts. */
&& !$ob->mbox->remote_mbox) {
if ($ob->mbox->access_expunge) {
try {
if ($mark_seen) {
$imp_imap->store($ob->mbox, [
'add' => [Horde_Imap_Client::FLAG_SEEN],
'ids' => $ids_ob,
]);
}

$imp_imap->copy($ob->mbox, $trash, [
&& !$ob->mbox->remote_mbox
&& $ob->mbox->access_expunge) {
try {
if ($mark_seen) {
$imp_imap->store($ob->mbox, [
'add' => [Horde_Imap_Client::FLAG_SEEN],
'ids' => $ids_ob,
'move' => true,
]);
$affected_mailboxes[strval($ob->mbox)] = $ob->mbox;
$affected_mailboxes[strval($trash)] = $trash;
$processed = true;
} catch (IMP_Imap_Exception $e) {
if ($e->getCode() == $e::OVERQUOTA) {
$notification->push(
_('You are over your quota, so your messages will be permanently deleted instead of moved to the Trash mailbox.'),
'horde.warning'
);
}

$idx = new IMP_Indices($ob->mbox, $ob->uids);
return $idx->delete([
'keeplog' => !empty($opts['keeplog']),
'nuke' => true,
]);
}
$imp_imap->copy($ob->mbox, $trash, [
'ids' => $ids_ob,
'move' => true,
]);
$affected_mailboxes[strval($ob->mbox)] = $ob->mbox;
$affected_mailboxes[strval($trash)] = $trash;
$processed = true;
$moved_to_trash = true;
} catch (IMP_Imap_Exception $e) {
if ($e->getCode() == $e::OVERQUOTA) {
$notification->push(
_('You are over your quota, so your messages will be permanently deleted instead of moved to the Trash mailbox.'),
'horde.warning'
);

return false;
$idx = new IMP_Indices($ob->mbox, $ob->uids);
return $idx->delete([
'keeplog' => !empty($opts['keeplog']),
'nuke' => true,
]);
}

return false;
}
} else {
}

if (!$moved_to_trash) {
/* Delete message logs now. This may result in loss of message
* log data for messages that might not be deleted - i.e. if
* an error occurs. But 1) the user has already indicated they
Expand Down
Loading