Commit 26c1c483 authored by JC Brand's avatar JC Brand

MAM fix: Get newest page when not paging

This is done by using `before: ''` and filtering by `start`.
Otherwise we get the oldest page.
parent dcd14071
......@@ -168,11 +168,15 @@ export function fetchNewestMessages (model) {
// for earlier messages
if (most_recent_msg && !api.settings.get('clear_messages_on_reconnection')) {
const should_page = api.settings.get('mam_request_all_pages');
const stanza_id = most_recent_msg.get(`stanza_id ${model.get('jid')}`);
if (stanza_id) {
fetchArchivedMessages(model, { 'after': stanza_id }, should_page ? 'forwards' : null);
if (should_page) {
const stanza_id = most_recent_msg.get(`stanza_id ${model.get('jid')}`);
if (stanza_id) {
fetchArchivedMessages(model, { 'after': stanza_id }, 'forwards');
} else {
fetchArchivedMessages(model, { 'start': most_recent_msg.get('time') }, 'forwards');
}
} else {
fetchArchivedMessages(model, { 'start': most_recent_msg.get('time') }, should_page ? 'forwards' : null);
fetchArchivedMessages(model, { 'before': '', 'start': most_recent_msg.get('time') });
}
} else {
fetchArchivedMessages(model, { 'before': '' });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment