We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: oldest_message is undefined converse-mam-views.js:49:28
Probably happens if this.model.messages.length > 0, but getOldestMessage() returns undefined because none of the message types match.
this.model.messages.length > 0
getOldestMessage()
This obviously prevents the error, don't know if it masks a different error though.
diff --git a/src/converse-mam-views.js b/src/converse-mam-views.js index 93775a2..b5a532d 100644 --- a/src/converse-mam-views.js +++ b/src/converse-mam-views.js @@ -37,17 +37,21 @@ converse.plugins.add('converse-mam-views', { const { _converse } = this.__super__; if (this.content.scrollTop === 0 && this.model.messages.length) { const oldest_message = this.model.getOldestMessage(); - const by_jid = this.model.get('jid'); - const stanza_id = oldest_message && oldest_message.get(`stanza_id ${by_jid}`); - this.addSpinner(); - if (stanza_id) { - await this.model.fetchArchivedMessages({ - 'before': stanza_id - }); - } else { - await this.model.fetchArchivedMessages({ - 'end': oldest_message.get('time') - }); + + // oldest_message can be undefined despite model.messages.length > 0, because of the message_type check + if (oldest_message) { + const by_jid = this.model.get('jid'); + const stanza_id = oldest_message.get(`stanza_id ${by_jid}`); + this.addSpinner(); + if (stanza_id) { + await this.model.fetchArchivedMessages({ + 'before': stanza_id + }); + } else { + await this.model.fetchArchivedMessages({ + 'end': oldest_message.get('time') + }); + }
The text was updated successfully, but these errors were encountered:
46ccc1a
Thanks, your assessment was correct.
Sorry, something went wrong.
No branches or pull requests
TypeError: oldest_message is undefined converse-mam-views.js:49:28
Probably happens if
this.model.messages.length > 0
, butgetOldestMessage()
returns undefined because none of the message types match.This obviously prevents the error, don't know if it masks a different error though.
The text was updated successfully, but these errors were encountered: