Commit 46ccc1a8 authored by JC Brand's avatar JC Brand

Fixes #1692

parent cc91f375
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
different path, you'll need to set `publicPath` in `webpack.config.js` to different path, you'll need to set `publicPath` in `webpack.config.js` to
your preferred path and then rebuild all assets (e.g. `make dist`). your preferred path and then rebuild all assets (e.g. `make dist`).
- Use `listenTo` to avoid memory leaks when views get removed. - Use `listenTo` to avoid memory leaks when views get removed.
- #1692 Bugfix: `TypeError: oldest_message is undefined`
## 5.0.1 (2019-08-14) ## 5.0.1 (2019-08-14)
......
...@@ -37,19 +37,21 @@ converse.plugins.add('converse-mam-views', { ...@@ -37,19 +37,21 @@ converse.plugins.add('converse-mam-views', {
const { _converse } = this.__super__; const { _converse } = this.__super__;
if (this.content.scrollTop === 0 && this.model.messages.length) { if (this.content.scrollTop === 0 && this.model.messages.length) {
const oldest_message = this.model.getOldestMessage(); const oldest_message = this.model.getOldestMessage();
const by_jid = this.model.get('jid'); if (oldest_message) {
const stanza_id = oldest_message && oldest_message.get(`stanza_id ${by_jid}`); const by_jid = this.model.get('jid');
this.addSpinner(); const stanza_id = oldest_message && oldest_message.get(`stanza_id ${by_jid}`);
if (stanza_id) { this.addSpinner();
await this.model.fetchArchivedMessages({ if (stanza_id) {
'before': stanza_id await this.model.fetchArchivedMessages({
}); 'before': stanza_id
} else { });
await this.model.fetchArchivedMessages({ } else {
'end': oldest_message.get('time') await this.model.fetchArchivedMessages({
}); 'end': oldest_message.get('time')
});
}
this.clearSpinner();
} }
this.clearSpinner();
} }
} }
}, },
......
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