Skip to content

fix: MsgBunch not firing after Msg sometimes#8259

Draft
WofWca wants to merge 1 commit into
mainfrom
wofwca/fix-IncomingMsgBunch
Draft

fix: MsgBunch not firing after Msg sometimes#8259
WofWca wants to merge 1 commit into
mainfrom
wofwca/fix-IncomingMsgBunch

Conversation

@WofWca
Copy link
Copy Markdown
Collaborator

@WofWca WofWca commented May 20, 2026

Closes #8232.

receive_imf_inner, and thus its only caller fetch_many_msgs,
seems to be the main function,
apart from add_device_msg_with_importance and handle_call_msg,
that fires IncomingMsg events.
However, fetch_many_msgs gets called in two places,
only one of which fires IncomingMsgBunch.

Let's fix that by moving IncomingMsgBunch
to inside of fetch_many_msgs.

Edit: I got some help from AI to write the impl AsyncFnMut(u32, Option<ReceivedMsg>) -> Result<()> part, but the rest is mine.

Closes #8232.

`receive_imf_inner`, and thus its only caller `fetch_many_msgs`,
seems to be the main function,
apart from `add_device_msg_with_importance` and `handle_call_msg`,
that fires `IncomingMsg` events.
However, `fetch_many_msgs` gets called in two places,
only one of which fires `IncomingMsgBunch`.

Let's fix that by moving `IncomingMsgBunch`
to inside of `fetch_many_msgs`.
@WofWca
Copy link
Copy Markdown
Collaborator Author

WofWca commented May 20, 2026

Hmmm the errors seem legit though they're in a completely different place. Guess that could be caused by my closure usage? Weird.

Comment thread src/imap.rs
Ok(msg) => msg,
};
received_msgs_channel
.send((request_uid, received_msg))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only place where Some is passed to received_msgs_channel, so there's no need in on_msg_received closure, you can just set some flag here and then emit EventType::IncomingMsgBunch right from this function if the flag is set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DC_EVENT_INCOMING_MSG sometimes not followed by DC_EVENT_INCOMING_MSG_BUNCH

2 participants