diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 3c3eb89..2cf3064 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -3,6 +3,7 @@ Changelog
3.2.3 (Unreleased)
--------------------
+- Fix #400: Fixed missing `not saved` warning
- Enh #411: Standardization of Modal Button Positions
3.2.2 (July 9, 2024)
diff --git a/module.json b/module.json
index 49c8dea..64b6aa6 100644
--- a/module.json
+++ b/module.json
@@ -10,7 +10,7 @@
],
"version": "3.2.3",
"humhub": {
- "minVersion": "1.16"
+ "minVersion": "1.17"
},
"homepage": "https://github.com/humhub/mail",
"authors": [
diff --git a/resources/js/humhub.mail.ConversationView.js b/resources/js/humhub.mail.ConversationView.js
index 94bbc54..0ecffc0 100644
--- a/resources/js/humhub.mail.ConversationView.js
+++ b/resources/js/humhub.mail.ConversationView.js
@@ -31,6 +31,15 @@ humhub.module('mail.ConversationView', function (module, require, $) {
});
};
+ ConversationView.prototype.onbeforeunloadCheck = function () {
+ var replyRichtext = this.getReplyRichtext();
+ if (replyRichtext && $(replyRichtext.$[0]).closest('form').find('textarea').val().trim().length) {
+ return client.confirmUnload();
+ }
+
+ return true;
+ };
+
ConversationView.prototype.loader = function (load) {
if (load !== false) {
loader.set(this.$);
@@ -172,6 +181,10 @@ humhub.module('mail.ConversationView', function (module, require, $) {
};
ConversationView.prototype.loadMessage = function (evt) {
+ if (!this.onbeforeunloadCheck()) {
+ return false;
+ }
+
var messageId = object.isNumber(evt) ? evt : evt.$trigger.data('message-id');
var that = this;
this.loader();
diff --git a/resources/js/humhub.mail.messenger.bundle.js b/resources/js/humhub.mail.messenger.bundle.js
index 8a3d60b..ca889f2 100644
--- a/resources/js/humhub.mail.messenger.bundle.js
+++ b/resources/js/humhub.mail.messenger.bundle.js
@@ -31,6 +31,15 @@ humhub.module('mail.ConversationView', function (module, require, $) {
});
};
+ ConversationView.prototype.onbeforeunloadCheck = function () {
+ var replyRichtext = this.getReplyRichtext();
+ if (replyRichtext && $(replyRichtext.$[0]).closest('form').find('textarea').val().trim().length) {
+ return client.confirmUnload();
+ }
+
+ return true;
+ };
+
ConversationView.prototype.loader = function (load) {
if (load !== false) {
loader.set(this.$);
@@ -172,6 +181,10 @@ humhub.module('mail.ConversationView', function (module, require, $) {
};
ConversationView.prototype.loadMessage = function (evt) {
+ if (!this.onbeforeunloadCheck()) {
+ return false;
+ }
+
var messageId = object.isNumber(evt) ? evt : evt.$trigger.data('message-id');
var that = this;
this.loader();
@@ -415,7 +428,7 @@ humhub.module('mail.ConversationView', function (module, require, $) {
module.export = ConversationView;
});
-
+
humhub.module('mail.ConversationEntry', function (module, require, $) {
var Widget = require('ui.widget').Widget;
@@ -439,7 +452,7 @@ 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;
@@ -703,7 +716,7 @@ humhub.module('mail.inbox', function (module, require, $) {
toggleInbox: toggleInbox
});
});
-
+
humhub.module('mail.conversation', function (module, require, $) {
var Widget = require('ui.widget').Widget;
var modal = require('ui.modal');
diff --git a/resources/js/humhub.mail.messenger.bundle.min.js b/resources/js/humhub.mail.messenger.bundle.min.js
index cfc40c5..3f188e1 100644
--- a/resources/js/humhub.mail.messenger.bundle.min.js
+++ b/resources/js/humhub.mail.messenger.bundle.min.js
@@ -1 +1 @@
-humhub.module("mail.ConversationView",function(r,t,n){var s=t("ui.widget").Widget,a=t("ui.loader"),c=t("client"),o=t("ui.additions"),e=t("util.object"),i=t("mail.notification"),l=t("ui.view"),u=s.extend();u.prototype.init=function(){o.observe(this.$);var e=this;window.onresize=function(t){e.updateSize(!0)},this.getActiveMessageId()||this.setActiveMessageId(s.instance("#inbox").getFirstMessageId()),this.reload(),this.$.on("mouseenter",".mail-conversation-entry",function(){n(this).find(".conversation-menu").show()}).on("mouseleave",".mail-conversation-entry",function(){n(this).find(".conversation-menu").hide()})},u.prototype.loader=function(t){!1!==t?a.set(this.$):a.reset(this.$)},u.prototype.markSeen=function(t){c.post(this.options.markSeenUrl,{data:{id:t}}).then(function(t){e.isDefined(t.messageCount)&&i.setMailMessageCount(t.messageCount)}).catch(function(t){r.log.error(t)})},u.prototype.loadUpdate=function(){var t=this.$.find(".mail-conversation-entry:not(.own):last").data("entry-id"),t={id:this.getActiveMessageId(),from:t},e=this;c.get(this.options.loadUpdateUrl,{data:t}).then(function(t){t.html&&n(t.html).each(function(){e.appendEntry(n(this))})})},u.prototype.reply=function(e){var o=this;c.submit(e).then(function(t){t.success?o.appendEntry(t.content).then(function(){o.$.find(".time").timeago();var t=o.getReplyRichtext(),t=(t&&t.$.trigger("clear"),o.getReplyFilePreview());t.length&&(t.hide(),t.children("ul.files").html("")),o.scrollToBottom(),l.isSmall()||o.focus(),s.instance("#inbox").updateEntries([o.getActiveMessageId()]),o.setLivePollInterval()}):r.log.error(t,!0)}).catch(function(t){r.log.error(t,!0)}).finally(function(t){a.reset(n(".reply-button")),e.finish()})},u.prototype.setLivePollInterval=function(){t("live").setDelay(5)},u.prototype.getReplyRichtext=function(){return s.instance(this.$.find(".ProsemirrorEditor"))},u.prototype.getReplyFilePreview=function(){return this.$.find(".post-file-list")},u.prototype.focus=function(t){var e=this.getReplyRichtext();e&&e.focus()},u.prototype.canLoadMore=function(){return!this.options.isLast},u.prototype.reload=function(){this.getActiveMessageId()&&this.loadMessage(this.getActiveMessageId())},u.prototype.addUser=function(t){var e=this;c.submit(t).then(function(t){t.result?e.$.find("#mail-conversation-header").html(t.result):t.error&&r.log.error(t,!0)}).catch(function(t){r.log.error(t,!0)})},u.prototype.appendEntry=function(t){var o,i=this,t=n(t);return i.$.find('[data-entry-id="'+t.data("entryId")+'"]').length?Promise.resolve():((o=t.not("script, link").filter(function(){return 1===this.nodeType})).css("opacity",0),this.getListNode().append(t),new Promise(function(t,e){o.css("opacity",1).fadeIn("fast",function(){i.onUpdate(),setTimeout(function(){i.scrollToBottom()},100),t()})}))},u.prototype.loadMessage=function(o){var i=e.isNumber(o)?o:o.$trigger.data("message-id"),n=this;this.loader(),c.get(this.options.loadMessageUrl,{data:{id:i}}).then(function(t){n.setActiveMessageId(i),n.options.isLast=!1;var e=s.instance("#inbox");return e.updateActiveItem(),e.hide(),o.$trigger&&history&&history.replaceState&&(e=o.$trigger.data("action-url"))&&history.replaceState(null,null,e),n.$.css("visibility","hidden"),n.updateContent(t.html)}).then(function(){return n.initScroll()}).catch(function(t){r.log.error(t,!0)}).finally(function(){n.loader(!1),n.$.css("visibility","visible"),n.initReplyRichText()})},u.prototype.initReplyRichText=function(){var t,e,o=this;window.ResizeObserver&&(t=new ResizeObserver(function(t){o.updateSize(o.isScrolledToBottom(100))}),e=o.getReplyRichtext())&&t.observe(e.$[0]),o.getReplyFilePreview().on("DOMSubtreeModified",function(t){o.updateSize(!0)}),o.focus()},u.prototype.isScrolledToBottom=function(t){if(!this.getListNode().length)return!1;t=t||0;var e=this.getListNode()[0];return e.scrollHeight-e.offsetHeight-e.scrollTop<=t},u.prototype.initScroll=function(){var e,t,o,i;if(window.IntersectionObserver)return e=this.getListNode(),t=n('
").addClass("conversation-scroll-down-button").html('
').on("click",()=>this.scrollToBottom()),this.getListNode().append(this.scrollDownButton)),this.scrollDownButton},u.prototype.loadMore=function(){var o=this,t={id:this.getActiveMessageId(),from:this.$.find(".mail-conversation-entry:first").data("entryId")};return c.get(this.options.loadMoreUrl,{data:t}).then(function(t){var e;t.result&&(e=n(t.result).hide(),o.getListNode().find(".conversation-stream-end").after(e),e.fadeIn()),o.options.isLast=!t.result||t.isLast}).catch(function(t){r.log.error(t,!0)})},u.prototype.preventScrollLoading=function(){return this.scrollLock||!this.canLoadMore()},u.prototype.canLoadMore=function(){return!this.options.isLast},u.prototype.assureScroll=function(){var t=this,e=this.getListNode();return e[0].offsetHeight>=e[0].scrollHeight&&this.canLoadMore()?this.loadMore().then(function(){return t.assureScroll()}).catch(function(){return Promise.resolve()}):t.scrollToBottom()},u.prototype.updateContent=function(e){var o=this;return new Promise(function(t){o.$.html(e),t()})},u.prototype.getActiveMessageId=function(){return this.options.messageId},u.prototype.setActiveMessageId=function(t){this.options.messageId=t},u.prototype.scrollToBottom=function(){var o=this;return new Promise(function(e){setTimeout(function(){o.$.imagesLoaded(function(){var t=o.getListNode();t.length&&o.updateSize(!1).then(function(){t[0].scrollTop=t[0].scrollHeight,e()})})})})},u.prototype.updateSize=function(n){var r=this;return new Promise(function(i){setTimeout(function(){var t,e,o=r.getListNode();o.length&&(t=(t=r.getReplyRichtext())?t.$.closest(".mail-message-form").innerHeight():0,o.css("margin-bottom",t+5+"px"),e=r.getListNode().offset().top,e=window.innerHeight-e-t-(l.isSmall()?20:30)+"px",o.css("height",e),o.css("max-height",e),!1!==n&&r.scrollToBottom(),i())},100)})},u.prototype.getListNode=function(){return this.$.find(".conversation-entry-list")},u.prototype.onUpdate=function(){l.isLarge()&&this.getListNode().getNiceScroll().resize()},r.export=u}),humhub.module("mail.ConversationEntry",function(t,e,i){e=e("ui.widget").Widget.extend();e.prototype.replace=function(t){var e=this,o=i(t).hide();this.$.fadeOut(function(){i(this).replaceWith(o),e.$=o,e.$.fadeIn("slow")})},e.prototype.remove=function(){this.$.fadeToggle("slow",function(){i(this).remove()})},t.export=e}),humhub.module("mail.inbox",function(n,t,r){var e=t("ui.widget").Widget,o=t("ui.filter").Filter,i=t("ui.view"),s=t("ui.loader"),a=t("client"),t=o.extend(),o=(t.prototype.triggerChange=function(){this.super("triggerChange"),this.updateFilterCount()},t.prototype.updateFilterCount=function(){var t=this.getActiveFilterCount(),e=this.$.find("#conversation-filter-link"),o=e.find(".filterCount");t?(o=o.length?o:r('
').insertBefore(e.find(".caret"))).html("
("+t+") "):o.length&&o.remove()},e.extend()),c=(o.prototype.init=function(){this.filter=e.instance("#mail-filter-root"),this.initScroll(),this.initHeight();var t=this;this.filter.off("afterChange.inbox").on("afterChange.inbox",function(){t.reload().then(function(){t.updateActiveItem()})}),i.isLarge()&&this.$.niceScroll({cursorwidth:"7",cursorborder:"",cursorcolor:"#555",cursoropacitymax:"0.2",nativeparentscrolling:!1,railpadding:{top:0,right:3,left:0,bottom:0}}),this.$.on("click",".entry",function(){t.$.find(".entry").removeClass("selected"),r(this).addClass("selected")})},o.prototype.initHeight=function(){var t=this.$.offset().top;this.$.css("max-height",window.innerHeight-t-15+"px")},o.prototype.updateEntries=function(t){var o=this;t.length&&a.get(this.options.updateEntriesUrl,{data:{ids:t}}).then(function(t){t.result&&(r.each(t.result,function(t,e){t=o.getEntry(t);t.length?t.replaceWith(e):r(e).prependTo(o.$)}),o.updateActiveItem())}).catch(function(t){n.log.error(t)})},o.prototype.getEntry=function(t){return this.$.find('[data-message-id="'+t+'"]')},o.prototype.initScroll=function(){var t,e,o;window.IntersectionObserver&&(t=r('
'),this.$.append(t),e=this,o=new IntersectionObserver(function(t){e.preventScrollLoading()||t.length&&t[0].isIntersecting&&(s.append(e.$),e.loadMore().finally(function(){s.reset(e.$)}))},{root:this.$[0],rootMargin:"50px"}),this.assureScroll().then(function(){o.observe(t[0])}))},o.prototype.assureScroll=function(){var t=this;return this.$[0].offsetHeight>=this.$[0].scrollHeight&&this.canLoadMore()?this.loadMore().then(function(){return t.assureScroll()}).catch(function(){return Promise.resolve()}):Promise.resolve()},o.prototype.loadMore=function(){var i=this;return new Promise(function(e,o){var t=i.filter.getFilterMap();t.from=i.getLastMessageId(),a.get(i.options.loadMoreUrl,{data:t}).then(function(t){t.result&&(r(t.result).insertBefore(".inbox-stream-end"),i.$.find(".inbox-stream-end").append()),i.options.isLast=!t.result||t.isLast,i.updateActiveItem(),e()}).catch(function(t){n.log.error(t,!0),o()}).finally(function(){i.scrollLock=!1})})},o.prototype.preventScrollLoading=function(){return this.scrollLock||!this.canLoadMore()},o.prototype.canLoadMore=function(){return!this.options.isLast},o.prototype.getReloadOptions=function(){return{data:this.filter.getFilterMap()}},o.prototype.updateActiveItem=function(){var t;this.$.find(".entry").removeClass("selected"),l()&&(t=this.$.find('[data-message-id="'+l().getActiveMessageId()+'"]')).length&&t.removeClass("unread").addClass("selected")},o.prototype.getFirstMessageId=function(){return this.$.find(".entry:first").data("message-id")},o.prototype.getLastMessageId=function(){return this.$.find(".entry:last").data("message-id")},o.prototype.hide=function(){return new Promise(function(t){i.isSmall()&&r(".mail-conversation-single-message").length&&r(".inbox-wrapper").slideUp(function(){l()&&l().updateSize(),t()}),t()})},o.prototype.show=function(){return new Promise(function(t){i.isSmall()&&r(".inbox-wrapper").slideDown(function(){l()&&l().updateSize(),t()}),t()})},null),l=function(){return c=c||e.instance("#mail-conversation-root")};n.export({ConversationList:o,Filter:t,setTagFilter:function(t){e.instance("#inbox").show().then(function(){r("#mail-filter-menu").collapse("show"),e.instance("#inbox-tag-picker").setSelection([{id:t.$trigger.data("tagId"),text:t.$trigger.data("tagName"),image:t.$trigger.data("tagImage")}])})},toggleInbox:function(){i.isSmall()&&r(".inbox-wrapper").slideToggle(function(){l()&&l().updateSize()})}})}),humhub.module("mail.conversation",function(i,t,r){function n(t){return s.instance('.mail-conversation-entry[data-entry-id="'+t+'"]')}var s=t("ui.widget").Widget,a=t("ui.modal"),o=t("client"),e=t("event"),c=t("mail.notification");i.export({init:function(){e.on("humhub:modules:mail:live:NewUserMessage",function(t,e){var o,i,n;r("#inbox").length&&(o=s.instance("#mail-conversation-root"),i=!1,n=[],e.forEach(function(t){n.push(t.data.message_id),!i&&o&&o.options.messageId==t.data.message_id&&(o.loadUpdate(),i=!0,o.markSeen(t.data.message_id))}),s.instance("#inbox").updateEntries(n))}).on("humhub:modules:mail:live:UserMessageDeleted",function(t,e,o){r("#inbox").length&&e.forEach(function(t){var e=n(t.data.entry_id);e&&e.remove(),c.setMailMessageCount(t.data.count)})})},linkAction:function(t){o.post(t).then(function(t){t.redirect&&o.pjax.redirect(t.redirect)}).catch(function(t){i.log.error(t,!0)})},submitEditEntry:function(o){a.submit(o).then(function(t){var e;t.success?(e=n(o.$trigger.data("entry-id")))&&setTimeout(function(){e.replace(t.content)},300):i.log.error(null,!0)}).catch(function(t){i.log.error(t,!0)})},deleteEntry:function(t){var e=n(t.$trigger.data("entry-id"));e?o.post(e.options.deleteUrl).then(function(t){a.global.close(),t.success&&setTimeout(function(){e.remove()},1e3)}).catch(function(t){i.log.error(t,!0)}):i.log.error(null,!0)}})});
\ No newline at end of file
+humhub.module("mail.ConversationView",function(r,t,n){var s=t("ui.widget").Widget,a=t("ui.loader"),c=t("client"),o=t("ui.additions"),e=t("util.object"),i=t("mail.notification"),l=t("ui.view"),u=s.extend();u.prototype.init=function(){o.observe(this.$);var e=this;window.onresize=function(t){e.updateSize(!0)},this.getActiveMessageId()||this.setActiveMessageId(s.instance("#inbox").getFirstMessageId()),this.reload(),this.$.on("mouseenter",".mail-conversation-entry",function(){n(this).find(".conversation-menu").show()}).on("mouseleave",".mail-conversation-entry",function(){n(this).find(".conversation-menu").hide()})},u.prototype.onbeforeunloadCheck=function(){var t=this.getReplyRichtext();return!t||!n(t.$[0]).closest("form").find("textarea").val().trim().length||c.confirmUnload()},u.prototype.loader=function(t){!1!==t?a.set(this.$):a.reset(this.$)},u.prototype.markSeen=function(t){c.post(this.options.markSeenUrl,{data:{id:t}}).then(function(t){e.isDefined(t.messageCount)&&i.setMailMessageCount(t.messageCount)}).catch(function(t){r.log.error(t)})},u.prototype.loadUpdate=function(){var t=this.$.find(".mail-conversation-entry:not(.own):last").data("entry-id"),t={id:this.getActiveMessageId(),from:t},e=this;c.get(this.options.loadUpdateUrl,{data:t}).then(function(t){t.html&&n(t.html).each(function(){e.appendEntry(n(this))})})},u.prototype.reply=function(e){var o=this;c.submit(e).then(function(t){t.success?o.appendEntry(t.content).then(function(){o.$.find(".time").timeago();var t=o.getReplyRichtext(),t=(t&&t.$.trigger("clear"),o.getReplyFilePreview());t.length&&(t.hide(),t.children("ul.files").html("")),o.scrollToBottom(),l.isSmall()||o.focus(),s.instance("#inbox").updateEntries([o.getActiveMessageId()]),o.setLivePollInterval()}):r.log.error(t,!0)}).catch(function(t){r.log.error(t,!0)}).finally(function(t){a.reset(n(".reply-button")),e.finish()})},u.prototype.setLivePollInterval=function(){t("live").setDelay(5)},u.prototype.getReplyRichtext=function(){return s.instance(this.$.find(".ProsemirrorEditor"))},u.prototype.getReplyFilePreview=function(){return this.$.find(".post-file-list")},u.prototype.focus=function(t){var e=this.getReplyRichtext();e&&e.focus()},u.prototype.canLoadMore=function(){return!this.options.isLast},u.prototype.reload=function(){this.getActiveMessageId()&&this.loadMessage(this.getActiveMessageId())},u.prototype.addUser=function(t){var e=this;c.submit(t).then(function(t){t.result?e.$.find("#mail-conversation-header").html(t.result):t.error&&r.log.error(t,!0)}).catch(function(t){r.log.error(t,!0)})},u.prototype.appendEntry=function(t){var o,i=this,t=n(t);return i.$.find('[data-entry-id="'+t.data("entryId")+'"]').length?Promise.resolve():((o=t.not("script, link").filter(function(){return 1===this.nodeType})).css("opacity",0),this.getListNode().append(t),new Promise(function(t,e){o.css("opacity",1).fadeIn("fast",function(){i.onUpdate(),setTimeout(function(){i.scrollToBottom()},100),t()})}))},u.prototype.loadMessage=function(o){if(!this.onbeforeunloadCheck())return!1;var i=e.isNumber(o)?o:o.$trigger.data("message-id"),n=this;this.loader(),c.get(this.options.loadMessageUrl,{data:{id:i}}).then(function(t){n.setActiveMessageId(i),n.options.isLast=!1;var e=s.instance("#inbox");return e.updateActiveItem(),e.hide(),o.$trigger&&history&&history.replaceState&&(e=o.$trigger.data("action-url"))&&history.replaceState(null,null,e),n.$.css("visibility","hidden"),n.updateContent(t.html)}).then(function(){return n.initScroll()}).catch(function(t){r.log.error(t,!0)}).finally(function(){n.loader(!1),n.$.css("visibility","visible"),n.initReplyRichText()})},u.prototype.initReplyRichText=function(){var t,e,o=this;window.ResizeObserver&&(t=new ResizeObserver(function(t){o.updateSize(o.isScrolledToBottom(100))}),e=o.getReplyRichtext())&&t.observe(e.$[0]),o.getReplyFilePreview().on("DOMSubtreeModified",function(t){o.updateSize(!0)}),o.focus()},u.prototype.isScrolledToBottom=function(t){if(!this.getListNode().length)return!1;t=t||0;var e=this.getListNode()[0];return e.scrollHeight-e.offsetHeight-e.scrollTop<=t},u.prototype.initScroll=function(){var e,t,o,i;if(window.IntersectionObserver)return e=this.getListNode(),t=n('
'),e.prepend(t),o=this,i=new IntersectionObserver(function(t){o.preventScrollLoading()||t.length&&t[0].isIntersecting&&(a.prepend(e),o.loadMore().finally(function(){a.reset(e)}))},{root:e[0],rootMargin:"50px"}),this.assureScroll().then(function(){i.observe(t[0]),l.isLarge()&&(o.getListNode().niceScroll({cursorwidth:"7",cursorborder:"",cursorcolor:"#555",cursoropacitymax:"0.2",nativeparentscrolling:!1,railpadding:{top:0,right:0,left:0,bottom:0}}),o.scrollDownButton=void 0,o.getListNode().on("scroll",()=>o.getScrollDownButton().toggle(!o.isScrolledToBottom())))})},u.prototype.getScrollDownButton=function(){return"object"!=typeof this.scrollDownButton&&(this.scrollDownButton=n("
").addClass("conversation-scroll-down-button").html('
').on("click",()=>this.scrollToBottom()),this.getListNode().append(this.scrollDownButton)),this.scrollDownButton},u.prototype.loadMore=function(){var o=this,t={id:this.getActiveMessageId(),from:this.$.find(".mail-conversation-entry:first").data("entryId")};return c.get(this.options.loadMoreUrl,{data:t}).then(function(t){var e;t.result&&(e=n(t.result).hide(),o.getListNode().find(".conversation-stream-end").after(e),e.fadeIn()),o.options.isLast=!t.result||t.isLast}).catch(function(t){r.log.error(t,!0)})},u.prototype.preventScrollLoading=function(){return this.scrollLock||!this.canLoadMore()},u.prototype.canLoadMore=function(){return!this.options.isLast},u.prototype.assureScroll=function(){var t=this,e=this.getListNode();return e[0].offsetHeight>=e[0].scrollHeight&&this.canLoadMore()?this.loadMore().then(function(){return t.assureScroll()}).catch(function(){return Promise.resolve()}):t.scrollToBottom()},u.prototype.updateContent=function(e){var o=this;return new Promise(function(t){o.$.html(e),t()})},u.prototype.getActiveMessageId=function(){return this.options.messageId},u.prototype.setActiveMessageId=function(t){this.options.messageId=t},u.prototype.scrollToBottom=function(){var o=this;return new Promise(function(e){setTimeout(function(){o.$.imagesLoaded(function(){var t=o.getListNode();t.length&&o.updateSize(!1).then(function(){t[0].scrollTop=t[0].scrollHeight,e()})})})})},u.prototype.updateSize=function(n){var r=this;return new Promise(function(i){setTimeout(function(){var t,e,o=r.getListNode();o.length&&(t=(t=r.getReplyRichtext())?t.$.closest(".mail-message-form").innerHeight():0,o.css("margin-bottom",t+5+"px"),e=r.getListNode().offset().top,e=window.innerHeight-e-t-(l.isSmall()?20:30)+"px",o.css("height",e),o.css("max-height",e),!1!==n&&r.scrollToBottom(),i())},100)})},u.prototype.getListNode=function(){return this.$.find(".conversation-entry-list")},u.prototype.onUpdate=function(){l.isLarge()&&this.getListNode().getNiceScroll().resize()},r.export=u}),humhub.module("mail.ConversationEntry",function(t,e,i){e=e("ui.widget").Widget.extend();e.prototype.replace=function(t){var e=this,o=i(t).hide();this.$.fadeOut(function(){i(this).replaceWith(o),e.$=o,e.$.fadeIn("slow")})},e.prototype.remove=function(){this.$.fadeToggle("slow",function(){i(this).remove()})},t.export=e}),humhub.module("mail.inbox",function(n,t,r){var e=t("ui.widget").Widget,o=t("ui.filter").Filter,i=t("ui.view"),s=t("ui.loader"),a=t("client"),t=o.extend(),o=(t.prototype.triggerChange=function(){this.super("triggerChange"),this.updateFilterCount()},t.prototype.updateFilterCount=function(){var t=this.getActiveFilterCount(),e=this.$.find("#conversation-filter-link"),o=e.find(".filterCount");t?(o=o.length?o:r('
').insertBefore(e.find(".caret"))).html("
("+t+") "):o.length&&o.remove()},e.extend()),c=(o.prototype.init=function(){this.filter=e.instance("#mail-filter-root"),this.initScroll(),this.initHeight();var t=this;this.filter.off("afterChange.inbox").on("afterChange.inbox",function(){t.reload().then(function(){t.updateActiveItem()})}),i.isLarge()&&this.$.niceScroll({cursorwidth:"7",cursorborder:"",cursorcolor:"#555",cursoropacitymax:"0.2",nativeparentscrolling:!1,railpadding:{top:0,right:3,left:0,bottom:0}}),this.$.on("click",".entry",function(){t.$.find(".entry").removeClass("selected"),r(this).addClass("selected")})},o.prototype.initHeight=function(){var t=this.$.offset().top;this.$.css("max-height",window.innerHeight-t-15+"px")},o.prototype.updateEntries=function(t){var o=this;t.length&&a.get(this.options.updateEntriesUrl,{data:{ids:t}}).then(function(t){t.result&&(r.each(t.result,function(t,e){t=o.getEntry(t);t.length?t.replaceWith(e):r(e).prependTo(o.$)}),o.updateActiveItem())}).catch(function(t){n.log.error(t)})},o.prototype.getEntry=function(t){return this.$.find('[data-message-id="'+t+'"]')},o.prototype.initScroll=function(){var t,e,o;window.IntersectionObserver&&(t=r('
'),this.$.append(t),e=this,o=new IntersectionObserver(function(t){e.preventScrollLoading()||t.length&&t[0].isIntersecting&&(s.append(e.$),e.loadMore().finally(function(){s.reset(e.$)}))},{root:this.$[0],rootMargin:"50px"}),this.assureScroll().then(function(){o.observe(t[0])}))},o.prototype.assureScroll=function(){var t=this;return this.$[0].offsetHeight>=this.$[0].scrollHeight&&this.canLoadMore()?this.loadMore().then(function(){return t.assureScroll()}).catch(function(){return Promise.resolve()}):Promise.resolve()},o.prototype.loadMore=function(){var i=this;return new Promise(function(e,o){var t=i.filter.getFilterMap();t.from=i.getLastMessageId(),a.get(i.options.loadMoreUrl,{data:t}).then(function(t){t.result&&(r(t.result).insertBefore(".inbox-stream-end"),i.$.find(".inbox-stream-end").append()),i.options.isLast=!t.result||t.isLast,i.updateActiveItem(),e()}).catch(function(t){n.log.error(t,!0),o()}).finally(function(){i.scrollLock=!1})})},o.prototype.preventScrollLoading=function(){return this.scrollLock||!this.canLoadMore()},o.prototype.canLoadMore=function(){return!this.options.isLast},o.prototype.getReloadOptions=function(){return{data:this.filter.getFilterMap()}},o.prototype.updateActiveItem=function(){var t;this.$.find(".entry").removeClass("selected"),l()&&(t=this.$.find('[data-message-id="'+l().getActiveMessageId()+'"]')).length&&t.removeClass("unread").addClass("selected")},o.prototype.getFirstMessageId=function(){return this.$.find(".entry:first").data("message-id")},o.prototype.getLastMessageId=function(){return this.$.find(".entry:last").data("message-id")},o.prototype.hide=function(){return new Promise(function(t){i.isSmall()&&r(".mail-conversation-single-message").length&&r(".inbox-wrapper").slideUp(function(){l()&&l().updateSize(),t()}),t()})},o.prototype.show=function(){return new Promise(function(t){i.isSmall()&&r(".inbox-wrapper").slideDown(function(){l()&&l().updateSize(),t()}),t()})},null),l=function(){return c=c||e.instance("#mail-conversation-root")};n.export({ConversationList:o,Filter:t,setTagFilter:function(t){e.instance("#inbox").show().then(function(){r("#mail-filter-menu").collapse("show"),e.instance("#inbox-tag-picker").setSelection([{id:t.$trigger.data("tagId"),text:t.$trigger.data("tagName"),image:t.$trigger.data("tagImage")}])})},toggleInbox:function(){i.isSmall()&&r(".inbox-wrapper").slideToggle(function(){l()&&l().updateSize()})}})}),humhub.module("mail.conversation",function(i,t,r){function n(t){return s.instance('.mail-conversation-entry[data-entry-id="'+t+'"]')}var s=t("ui.widget").Widget,a=t("ui.modal"),o=t("client"),e=t("event"),c=t("mail.notification");i.export({init:function(){e.on("humhub:modules:mail:live:NewUserMessage",function(t,e){var o,i,n;r("#inbox").length&&(o=s.instance("#mail-conversation-root"),i=!1,n=[],e.forEach(function(t){n.push(t.data.message_id),!i&&o&&o.options.messageId==t.data.message_id&&(o.loadUpdate(),i=!0,o.markSeen(t.data.message_id))}),s.instance("#inbox").updateEntries(n))}).on("humhub:modules:mail:live:UserMessageDeleted",function(t,e,o){r("#inbox").length&&e.forEach(function(t){var e=n(t.data.entry_id);e&&e.remove(),c.setMailMessageCount(t.data.count)})})},linkAction:function(t){o.post(t).then(function(t){t.redirect&&o.pjax.redirect(t.redirect)}).catch(function(t){i.log.error(t,!0)})},submitEditEntry:function(o){a.submit(o).then(function(t){var e;t.success?(e=n(o.$trigger.data("entry-id")))&&setTimeout(function(){e.replace(t.content)},300):i.log.error(null,!0)}).catch(function(t){i.log.error(t,!0)})},deleteEntry:function(t){var e=n(t.$trigger.data("entry-id"));e?o.post(e.options.deleteUrl).then(function(t){a.global.close(),t.success&&setTimeout(function(){e.remove()},1e3)}).catch(function(t){i.log.error(t,!0)}):i.log.error(null,!0)}})});
\ No newline at end of file
diff --git a/resources/js/humhub.mail.notification.min.js b/resources/js/humhub.mail.notification.min.js
index 89f505a..a68d8e3 100644
--- a/resources/js/humhub.mail.notification.min.js
+++ b/resources/js/humhub.mail.notification.min.js
@@ -1 +1 @@
-humhub.module("mail.notification",function(o,e,i){function n(){s.get(o.config.url.count).then(function(e){l(parseInt(e.newMessages))})}var a,s=e("client"),r=e("ui.loader"),t=e("event"),u=e("ui.widget").Widget,c=0,l=(o.initOnPjaxLoad=!0,function(e){var n=i("#badge-messages");e&&0!==parseInt(e)?(c=e,n.empty(),n.append(e),n.fadeIn("fast")):(n.css("display","none"),c=0),t.trigger("humhub:modules:notification:UpdateTitleNotificationCount")});o.export({init:function(e){e||(t.on("humhub:modules:mail:live:NewUserMessage",function(e,n){n=n[n.length-1];l(n.data.count)}).on("humhub:modules:mail:live:UserMessageDeleted",function(e,n){n=n[n.length-1];l(n.data.count)}),i("#icon-messages").click(function(){a&&a.abort();const n=i("#loader_messages"),t=n.parent();n.parent().find(":not(#loader_messages)").remove(),r.set(n.show()),s.get(o.config.url.list,{beforeSend:function(e){a=e}}).then(function(e){a=void 0,t.prepend(i(e.html)),n.hide(),t.niceScroll({cursorwidth:"7",cursorborder:"",cursorcolor:"#555",cursoropacitymax:"0.2",nativeparentscrolling:!1,railpadding:{top:0,right:3,left:0,bottom:0}})})})),n()},loadMessage:function(e){var n=u.instance("#mail-conversation-root");n&&"function"==typeof n.loadMessage?(n.loadMessage(e),n.$.closest(".container").addClass("mail-conversation-single-message")):s.redirect(e.url),e.finish()},setMailMessageCount:l,updateCount:n,getNewMessageCount:function(){return c}})});
\ No newline at end of file
+humhub.module("mail.notification",function(o,e,i){function n(){s.get(o.config.url.count).then(function(e){l(parseInt(e.newMessages))})}var a,s=e("client"),r=e("ui.loader"),t=e("event"),u=e("ui.widget").Widget,c=0,l=(o.initOnPjaxLoad=!0,function(e){var n=i("#badge-messages");e&&0!==parseInt(e)?(c=e,n.empty(),n.append(e),n.fadeIn("fast")):(n.css("display","none"),c=0),t.trigger("humhub:modules:notification:UpdateTitleNotificationCount")});o.export({init:function(e){e||(t.on("humhub:modules:mail:live:NewUserMessage",function(e,n){n=n[n.length-1];l(n.data.count)}).on("humhub:modules:mail:live:UserMessageDeleted",function(e,n){n=n[n.length-1];l(n.data.count)}),i("#icon-messages").click(function(){a&&a.abort();let n=i("#loader_messages"),t=n.parent();n.parent().find(":not(#loader_messages)").remove(),r.set(n.show()),s.get(o.config.url.list,{beforeSend:function(e){a=e}}).then(function(e){a=void 0,t.prepend(i(e.html)),n.hide(),t.niceScroll({cursorwidth:"7",cursorborder:"",cursorcolor:"#555",cursoropacitymax:"0.2",nativeparentscrolling:!1,railpadding:{top:0,right:3,left:0,bottom:0}})})})),n()},loadMessage:function(e){var n=u.instance("#mail-conversation-root");n&&"function"==typeof n.loadMessage?(n.loadMessage(e),n.$.closest(".container").addClass("mail-conversation-single-message")):s.redirect(e.url),e.finish()},setMailMessageCount:l,updateCount:n,getNewMessageCount:function(){return c}})});
\ No newline at end of file
diff --git a/widgets/ConversationView.php b/widgets/ConversationView.php
index a291d45..9697a39 100644
--- a/widgets/ConversationView.php
+++ b/widgets/ConversationView.php
@@ -8,6 +8,7 @@
namespace humhub\modules\mail\widgets;
+use Yii;
use humhub\widgets\JsWidget;
use humhub\modules\mail\helpers\Url;