Skip to content
New issue

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

WIP: Configurable Join & Left Messages #427

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

ArchBlood
Copy link

@ArchBlood ArchBlood commented Nov 5, 2024

This is an attempt to resolve #420

Screenshot_1
Screenshot_2
Screenshot_3

@ArchBlood ArchBlood marked this pull request as draft November 5, 2024 19:44
@ArchBlood
Copy link
Author

@luke- I'm not sure how we'd disable the count through the JavaScript side of things

humhub.module('mail.notification', function (module, require, $) {
var client = require('client');
var loader = require('ui.loader');
var event = require('event');
var Widget = require('ui.widget').Widget;
var currentXhr;
var newMessageCount = 0;
module.initOnPjaxLoad = true;
var init = function (isPjax) {
// open the messages menu
if (!isPjax) {
event.on('humhub:modules:mail:live:NewUserMessage', function (evt, events) {
var evtx = events[events.length - 1];
setMailMessageCount(evtx.data.count);
}).on('humhub:modules:mail:live:UserMessageDeleted', function (evt, events) {
var evtx = events[events.length - 1];
setMailMessageCount(evtx.data.count);
});
$('#icon-messages').click(function () {
if (currentXhr) {
currentXhr.abort();
}
const messageLoader = $('#loader_messages');
const messageList = messageLoader.parent();
// remove all <li> entries from dropdown
messageLoader.parent().find(':not(#loader_messages)').remove();
loader.set(messageLoader.show());
client.get(module.config.url.list, {
beforeSend: function (xhr) {
currentXhr = xhr;
}
}).then(function (response) {
currentXhr = undefined;
messageList.prepend($(response.html));
messageLoader.hide();
messageList.niceScroll({
cursorwidth: '7',
cursorborder: '',
cursorcolor: '#555',
cursoropacitymax: '0.2',
nativeparentscrolling: false,
railpadding: {top: 0, right: 3, left: 0, bottom: 0}
});
});
});
}
updateCount();
};
var updateCount = function () {
client.get(module.config.url.count).then(function (response) {
setMailMessageCount(parseInt(response.newMessages));
});
};
var setMailMessageCount = function (count) {
// show or hide the badge for new messages
var $badge = $('#badge-messages');
if (!count || parseInt(count) === 0) {
$badge.css('display', 'none');
newMessageCount = 0;
} else {
newMessageCount = count;
$badge.empty();
$badge.append(count);
$badge.fadeIn('fast');
}
event.trigger('humhub:modules:notification:UpdateTitleNotificationCount');
};
var loadMessage = function (evt) {
var root = Widget.instance('#mail-conversation-root');
if (root && typeof(root.loadMessage) === 'function') {
root.loadMessage(evt);
root.$.closest('.container').addClass('mail-conversation-single-message');
} else {
client.redirect(evt.url);
}
evt.finish();
};
var getNewMessageCount = function () {
return newMessageCount;
};
module.export({
init: init,
loadMessage: loadMessage,
setMailMessageCount: setMailMessageCount,
updateCount: updateCount,
getNewMessageCount: getNewMessageCount,
});
});

I'd also like to bring to HumHub's attention the following browser console error which seems to need to be addressed as well.

humhub-app.js?v=1730729097:1
[Deprecation] Listener added for a 'DOMSubtreeModified' mutation event.
Support for this event type has been removed, and this event will no longer be fired.
See https://chromestatus.com/feature/5083947249172480 for more information.

@luke-
Copy link
Contributor

luke- commented Nov 5, 2024

@ArchBlood Thank you for your work here. What do you think about following apporach? #420 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disable "Leave a Conversation" Notification
2 participants