Skip to content

Commit

Permalink
Fix undefined conversation view
Browse files Browse the repository at this point in the history
  • Loading branch information
yurabakhtin committed Apr 15, 2024
1 parent 2b24cf3 commit 847405b
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 36 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
3.2.1 (Unreleased)
------------------------
- Enh #370: Remove message entries on disable module
- Fix #385: Fix undefined conversation view

3.2.0 (January 29, 2024)
------------------------
Expand Down
36 changes: 21 additions & 15 deletions resources/js/humhub.mail.inbox.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
humhub.module('mail.inbox', function (module, require, $) {

var Widget = require('ui.widget').Widget;
var Filter = require('ui.filter').Filter;
var view = require('ui.view');
Expand Down Expand Up @@ -177,17 +176,14 @@ humhub.module('mail.inbox', function (module, require, $) {
};

ConversationList.prototype.updateActiveItem = function() {

var activeMessageId = Widget.instance('#mail-conversation-root').getActiveMessageId();

this.$.find('.entry').removeClass('selected');

// Set new selection
this.$.find('.entry').removeClass('selected');
var $selected = this.$.find('[data-message-id="' + activeMessageId + '"]');

if($selected.length) {
$selected.removeClass('unread').addClass('selected');
if (getRoot()) {
var $selected = this.$.find('[data-message-id="' + getRoot().getActiveMessageId() + '"]');
if ($selected.length) {
$selected.removeClass('unread').addClass('selected');
}
}
};

Expand All @@ -204,8 +200,8 @@ humhub.module('mail.inbox', function (module, require, $) {
return new Promise(function (resolve) {
if(view.isSmall() && $('.mail-conversation-single-message').length) {
$('.inbox-wrapper').slideUp(function() {
if($('#mail-conversation-root').length) {
Widget.instance('#mail-conversation-root').updateSize();
if (getRoot()) {
getRoot().updateSize();
}
resolve();
});
Expand All @@ -218,8 +214,8 @@ humhub.module('mail.inbox', function (module, require, $) {
return new Promise(function (resolve) {
if(view.isSmall()) {
$('.inbox-wrapper').slideDown(function() {
if($('#mail-conversation-root').length) {
Widget.instance('#mail-conversation-root').updateSize();
if (getRoot()) {
getRoot().updateSize();
}

resolve();
Expand All @@ -232,7 +228,9 @@ humhub.module('mail.inbox', function (module, require, $) {
var toggleInbox = function() {
if(view.isSmall()) {
$('.inbox-wrapper').slideToggle(function() {
Widget.instance('#mail-conversation-root').updateSize();
if (getRoot()) {
getRoot().updateSize();
}
});
}
};
Expand All @@ -248,10 +246,18 @@ humhub.module('mail.inbox', function (module, require, $) {
});
};

var root = null;
var getRoot = function () {
if (!root) {
root = Widget.instance('#mail-conversation-root');
}
return root;
};

module.export({
ConversationList: ConversationList,
Filter: ConversationFilter,
setTagFilter: setTagFilter,
toggleInbox: toggleInbox
});
});
});
37 changes: 22 additions & 15 deletions resources/js/humhub.mail.messenger.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,6 @@ humhub.module('mail.ConversationEntry', function (module, require, $) {
module.export = ConversationEntry;
});
humhub.module('mail.inbox', function (module, require, $) {

var Widget = require('ui.widget').Widget;
var Filter = require('ui.filter').Filter;
var view = require('ui.view');
Expand Down Expand Up @@ -619,17 +618,14 @@ humhub.module('mail.inbox', function (module, require, $) {
};

ConversationList.prototype.updateActiveItem = function() {

var activeMessageId = Widget.instance('#mail-conversation-root').getActiveMessageId();

this.$.find('.entry').removeClass('selected');

// Set new selection
this.$.find('.entry').removeClass('selected');
var $selected = this.$.find('[data-message-id="' + activeMessageId + '"]');

if($selected.length) {
$selected.removeClass('unread').addClass('selected');
if (getRoot()) {
var $selected = this.$.find('[data-message-id="' + getRoot().getActiveMessageId() + '"]');
if ($selected.length) {
$selected.removeClass('unread').addClass('selected');
}
}
};

Expand All @@ -646,8 +642,8 @@ humhub.module('mail.inbox', function (module, require, $) {
return new Promise(function (resolve) {
if(view.isSmall() && $('.mail-conversation-single-message').length) {
$('.inbox-wrapper').slideUp(function() {
if($('#mail-conversation-root').length) {
Widget.instance('#mail-conversation-root').updateSize();
if (getRoot()) {
getRoot().updateSize();
}
resolve();
});
Expand All @@ -660,8 +656,8 @@ humhub.module('mail.inbox', function (module, require, $) {
return new Promise(function (resolve) {
if(view.isSmall()) {
$('.inbox-wrapper').slideDown(function() {
if($('#mail-conversation-root').length) {
Widget.instance('#mail-conversation-root').updateSize();
if (getRoot()) {
getRoot().updateSize();
}

resolve();
Expand All @@ -674,7 +670,9 @@ humhub.module('mail.inbox', function (module, require, $) {
var toggleInbox = function() {
if(view.isSmall()) {
$('.inbox-wrapper').slideToggle(function() {
Widget.instance('#mail-conversation-root').updateSize();
if (getRoot()) {
getRoot().updateSize();
}
});
}
};
Expand All @@ -690,13 +688,22 @@ humhub.module('mail.inbox', function (module, require, $) {
});
};

var root = null;
var getRoot = function () {
if (!root) {
root = Widget.instance('#mail-conversation-root');
}
return root;
};

module.export({
ConversationList: ConversationList,
Filter: ConversationFilter,
setTagFilter: setTagFilter,
toggleInbox: toggleInbox
});
});
});

humhub.module('mail.conversation', function (module, require, $) {
var Widget = require('ui.widget').Widget;
var modal = require('ui.modal');
Expand Down
2 changes: 1 addition & 1 deletion resources/js/humhub.mail.messenger.bundle.min.js

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions resources/js/humhub.mail.notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ humhub.module('mail.notification', function (module, require, $) {
};

var loadMessage = function (evt) {
if ($('#mail-conversation-root').length) {
Widget.instance('#mail-conversation-root').loadMessage(evt);
$('#mail-conversation-root').closest('.container').addClass('mail-conversation-single-message');
var root = Widget.instance('#mail-conversation-root');
if (root) {
root.loadMessage(evt);
root.$.closest('.container').addClass('mail-conversation-single-message');
} else {
client.redirect(evt.url);
}
Expand All @@ -88,4 +89,4 @@ humhub.module('mail.notification', function (module, require, $) {
updateCount: updateCount,
getNewMessageCount: getNewMessageCount,
});
});
});
2 changes: 1 addition & 1 deletion resources/js/humhub.mail.notification.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 847405b

Please sign in to comment.