Git commit 0671e1af3432957839d1556fade9389141daf37b by Jan Kundr?t. Committed on 19/08/2013 at 14:40. Pushed by jkt into branch 'master'.
GUI: update mailbox contents whenever clicking through messages or mailboxes The IMAP code is currently multiplexing a single connection among many mailboxes. There are situations where a parallel action might switch away from the "currently selected" mailbox, at least as shown in the UI, to some other place. An example of such action is when the composer wants to make a message with the \Answered flag. Typically, the mailbox is automatically switched when the user opens a message -- either because of the request to have it marked as read, or because some of the parts are not available form the cache. However, if the message being opened was already cached and marked as read, no IMAP traffic was actually required, and therefore there was no reason for issuing a SELECT, either. This might or might not be the best fix -- from the user's point of view, it makes a lot of sense to receive updates about mailbox state as often as possible, and having the mailbox opened (with the usual IDLE or NOP polling) is the usual way to go. On the other hand, this might result in slightly bigger IMAP traffic, especially on servers which do not support CONDSTORE/QRESYNC. The ideal fix for the future is to switch to multiple connections, but that opens a whole new can of worms. In the meanwhile, let's just fulfil the naive expectation that clicking on any message in a mailbox (or any mailbox, for that matter) will at least refresh the current view. REVIEW: 112158 M +6 -2 src/Gui/Window.cpp M +5 -2 src/Imap/Model/MsgListModel.cpp http://commits.kde.org/trojita/0671e1af3432957839d1556fade9389141daf37b diff --git a/src/Gui/Window.cpp b/src/Gui/Window.cpp index 8ff0074..093c8e6 100644 --- a/src/Gui/Window.cpp +++ b/src/Gui/Window.cpp @@ -908,9 +908,13 @@ void MainWindow::msgListClicked(const QModelIndex &index) // Be sure to update the toolbar/actions with the state of the current message updateMessageFlags(); + // Because it's quite possible that we have switched into another mailbox, make sure that we're in the "current" one so that + // user will be notified about new arrivals, etc. + QModelIndex translated; + Imap::Mailbox::Model::realTreeItem(index, 0, &translated); + model->switchToMailbox(translated.parent().parent()); + if (index.column() == Imap::Mailbox::MsgListModel::SEEN) { - QModelIndex translated; - Imap::Mailbox::Model::realTreeItem(index, 0, &translated); if (!translated.data(Imap::Mailbox::RoleIsFetched).toBool()) return; Imap::Mailbox::FlagsOperation flagOp = translated.data(Imap::Mailbox::RoleMessageIsMarkedRead).toBool() ? diff --git a/src/Imap/Model/MsgListModel.cpp b/src/Imap/Model/MsgListModel.cpp index f5b4c72..9b8a80f 100644 --- a/src/Imap/Model/MsgListModel.cpp +++ b/src/Imap/Model/MsgListModel.cpp @@ -484,9 +484,12 @@ void MsgListModel::setMailbox(const QModelIndex &index) msgListPtr->resetWasUnreadState(); RESET_MODEL; emit mailboxChanged(index); - // We want to tell the Model that it should consider starting the IDLE command. - const_cast<Model *>(model)->switchToMailbox(index); } + + // We want to tell the Model that it should consider starting the IDLE command. + // This shall happen regardless on what this model's idea about a "current mailbox" is because the IMAP connection might have + // switched to another mailbox behind the scenes. + const_cast<Model *>(model)->switchToMailbox(index); } /** @short Change mailbox to the one specified by its name */