threads: recurse thread-subject check
Not only check for duplicate subjects in *siblings*, also recurse into the children. This remove some clutter from deeply nested threads. Fixes: #2078.
This commit is contained in:
@ -394,9 +394,8 @@ update_container (Container& container, bool descending,
|
|||||||
if (!container.children.empty())
|
if (!container.children.empty())
|
||||||
qmatch.flags |= QueryMatch::Flags::HasChild;
|
qmatch.flags |= QueryMatch::Flags::HasChild;
|
||||||
|
|
||||||
// see whether this message has the has the thread
|
// see whether this message has the thread subject, i.e., the
|
||||||
// subject, ie.. the first message in this thread with the
|
// first message in this thread with the given subject.
|
||||||
// given subject.
|
|
||||||
if (qmatch.has_flag(QueryMatch::Flags::Root) ||
|
if (qmatch.has_flag(QueryMatch::Flags::Root) ||
|
||||||
//qmatch.has_flag(QueryMatch::Flags::Orphan) ||
|
//qmatch.has_flag(QueryMatch::Flags::Orphan) ||
|
||||||
prev_subject.empty() ||
|
prev_subject.empty() ||
|
||||||
@ -428,20 +427,20 @@ update_container (Container& container, bool descending,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
update_containers (Containers& children, bool descending, ThreadPath& tpath,
|
update_containers (Containers& children, bool descending, ThreadPath& tpath,
|
||||||
size_t seg_size)
|
size_t seg_size, const std::string& prev_subject)
|
||||||
{
|
{
|
||||||
size_t idx{0};
|
size_t idx{0};
|
||||||
std::string last_subject;
|
std::string last_subject = prev_subject;
|
||||||
|
|
||||||
for (auto&& c: children) {
|
for (auto&& c: children) {
|
||||||
tpath.emplace_back(idx++);
|
tpath.emplace_back(idx++);
|
||||||
|
|
||||||
if (c->query_match) {
|
if (c->query_match) {
|
||||||
update_container(*c, descending, tpath, seg_size,
|
update_container(*c, descending, tpath, seg_size,
|
||||||
last_subject);
|
last_subject);
|
||||||
last_subject = c->query_match->subject;
|
last_subject = c->query_match->subject;
|
||||||
}
|
}
|
||||||
update_containers(c->children, descending, tpath, seg_size);
|
update_containers(c->children, descending, tpath, seg_size,
|
||||||
|
last_subject);
|
||||||
tpath.pop_back();
|
tpath.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -458,8 +457,11 @@ update_containers (ContainerVec& root_vec, bool descending, size_t n)
|
|||||||
size_t idx{0};
|
size_t idx{0};
|
||||||
for (auto&& c: root_vec) {
|
for (auto&& c: root_vec) {
|
||||||
tpath.emplace_back(idx++);
|
tpath.emplace_back(idx++);
|
||||||
update_container(*c, descending, tpath, seg_size);
|
std::string prev_subject;
|
||||||
update_containers(c->children, descending, tpath, seg_size);
|
if (update_container(*c, descending, tpath, seg_size))
|
||||||
|
prev_subject = c->query_match->subject;
|
||||||
|
update_containers(c->children, descending, tpath, seg_size,
|
||||||
|
prev_subject);
|
||||||
tpath.pop_back();
|
tpath.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user