- /* I hate do this here, since it's so low-level, but I'm not sure where
- * I can abstract it. Problem: the id and subj hashes lose their keys when
- * mutt_free_envelope gets called, but keep their spots in the hash. This
- * confuses threading. Alternatively we could try to merge the new
- * envelope into the old one. Also messy and lowlevel. */
- if (ctx->id_hash && h->env->message_id)
- hash_delete (ctx->id_hash, h->env->message_id, h, NULL);
- if (ctx->subj_hash && h->env->real_subj)
- hash_delete (ctx->subj_hash, h->env->real_subj, h, NULL);
- mutt_free_envelope (&h->env);
- h->env = mutt_read_rfc822_header (msg->fp, h, 0, 0);
- if (ctx->id_hash && h->env->message_id)
- hash_insert (ctx->id_hash, h->env->message_id, h, 0);
- if (ctx->subj_hash && h->env->real_subj)
- hash_insert (ctx->subj_hash, h->env->real_subj, h, 1);
+ newenv = mutt_read_rfc822_header (msg->fp, h, 0, 0);
+ mutt_merge_envelopes(h->env, &newenv);