Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use Thread::removeTag() when archiving a thread in the search view

  • Loading branch information...
commit c945edcc6282575c77d896d392cdbd21ca74c9a4 1 parent 0ecdf6c
Tomas Carnecky authored
Showing with 3 additions and 52 deletions.
  1. +1 −52 src/search_view.cc
  2. +2 −0  src/thread.cc
53 src/search_view.cc
View
@@ -192,24 +192,6 @@ void SearchView::openSelectedThread()
}
}
-void removeTagRecursive(notmuch_message_t *message, std::string tag)
-{
- notmuch_messages_t * replies;
- notmuch_message_remove_tag(message, "inbox");
-
- for (replies = notmuch_message_get_replies(message);
- notmuch_messages_valid(replies);
- notmuch_messages_move_to_next(replies))
- {
- notmuch_message_t * msg = notmuch_messages_get(replies);
- notmuch_message_remove_tag(msg, "inbox");
-
- removeTagRecursive(msg, tag);
- }
-
- notmuch_messages_destroy(replies);
-}
-
void SearchView::archiveSelectedThread()
{
std::lock_guard<std::mutex> lock(_mutex);
@@ -218,37 +200,7 @@ void SearchView::archiveSelectedThread()
{
try
{
- std::string id = _threads.at(_selectedIndex).id;
-
- notmuch_database_mode_t mode = NOTMUCH_DATABASE_MODE_READ_WRITE;
- notmuch_database_t * database = Notmuch::openDatabase(mode);
- notmuch_query_t * query = notmuch_query_create(database, ("thread:" + id).c_str());
- notmuch_threads_t * threads = notmuch_query_search_threads(query);
- notmuch_thread_t * thread = 0;
- notmuch_messages_t * messages;
-
- if (!notmuch_threads_valid(threads) || !(thread = notmuch_threads_get(threads)))
- {
- notmuch_threads_destroy(threads);
- notmuch_query_destroy(query);
-
- notmuch_database_close(database);
-
- throw InvalidThreadException(id);
- }
-
- for (messages = notmuch_thread_get_toplevel_messages(thread);
- notmuch_messages_valid(messages);
- notmuch_messages_move_to_next(messages))
- {
- removeTagRecursive(notmuch_messages_get(messages), "inbox");
- }
-
- notmuch_messages_destroy(messages);
- notmuch_threads_destroy(threads);
- notmuch_query_destroy(query);
-
- _threads.at(_selectedIndex).tags.erase("inbox");
+ _threads.at(_selectedIndex).removeTag("inbox");
next();
update();
@@ -350,7 +302,6 @@ void SearchView::collectThreads()
notmuch_thread_t * thread = notmuch_threads_get(threadIterator);
_threads.push_back(Thread(NULL, thread));
- notmuch_thread_destroy(thread);
_condition.notify_one();
@@ -360,8 +311,6 @@ void SearchView::collectThreads()
}
_collecting = false;
- notmuch_threads_destroy(threadIterator);
- notmuch_query_destroy(query);
/* For cases when there are no matching threads */
_condition.notify_one();
2  src/thread.cc
View
@@ -63,6 +63,8 @@ void Thread::topLevelMessages(std::vector<Message> & messages)
void Thread::removeTag(std::string tag)
{
+ tags.erase(tag);
+
std::vector<Message> messages;
topLevelMessages(messages);
Please sign in to comment.
Something went wrong with that request. Please try again.