Skip to content

Commit

Permalink
- Fix: Error thorwn if no lastEntry of conversation could be found
Browse files Browse the repository at this point in the history
- Fix: Script error logged in case conversation message list not found
  • Loading branch information
buddh4 committed Nov 5, 2020
1 parent 9f47a8c commit 80cb6a4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions models/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ public function delete()

public function getPreview()
{
if(!$this->lastEntry) {
return 'No message found';
}

return RichText::preview($this->lastEntry->content, 80);
}

Expand Down
10 changes: 10 additions & 0 deletions resources/js/humhub.mail.ConversationView.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ humhub.module('mail.ConversationView', function (module, require, $) {
};

ConversationView.prototype.isScrolledToBottom = function (tolerance) {
var $list = this.getListNode();

if(!$list.length) {
return false;
}

tolerance = tolerance || 0;
var list = this.getListNode()[0];
return list.scrollHeight - list.offsetHeight - list.scrollTop <= tolerance;
Expand Down Expand Up @@ -314,6 +320,10 @@ humhub.module('mail.ConversationView', function (module, require, $) {
setTimeout(function() {
that.$.imagesLoaded(function() {
var $list = that.getListNode();
if(!$list.length) {
return;
}

that.updateSize(false).then(function () {
$list[0].scrollTop = $list[0].scrollHeight;
resolve()
Expand Down
10 changes: 10 additions & 0 deletions resources/js/humhub.mail.messenger.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ humhub.module('mail.ConversationView', function (module, require, $) {
};

ConversationView.prototype.isScrolledToBottom = function (tolerance) {
var $list = this.getListNode();

if(!$list.length) {
return false;
}

tolerance = tolerance || 0;
var list = this.getListNode()[0];
return list.scrollHeight - list.offsetHeight - list.scrollTop <= tolerance;
Expand Down Expand Up @@ -314,6 +320,10 @@ humhub.module('mail.ConversationView', function (module, require, $) {
setTimeout(function() {
that.$.imagesLoaded(function() {
var $list = that.getListNode();
if(!$list.length) {
return;
}

that.updateSize(false).then(function () {
$list[0].scrollTop = $list[0].scrollHeight;
resolve()
Expand Down
Loading

0 comments on commit 80cb6a4

Please sign in to comment.