mirror of
https://github.com/twisterarmy/twister-html.git
synced 2025-02-05 03:24:17 +00:00
add sound and desktop notification and counter indication if we got new DMs in minimized modal
This commit is contained in:
parent
a6b89ce271
commit
0599685df4
@ -80,8 +80,12 @@ function requestDmConversation(postboard, peerAlias) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function processDmConversation(stream, peerAlias, posts) {
|
function processDmConversation(stream, peerAlias, posts) {
|
||||||
|
if (!isModalWithElemExists(stream))
|
||||||
|
return;
|
||||||
|
|
||||||
var streamItems = stream.children();
|
var streamItems = stream.children();
|
||||||
var streamPostsIDs = [];
|
var streamPostsIDs = [];
|
||||||
|
var newPosts = 0;
|
||||||
|
|
||||||
for (var i = 0; i < streamItems.length; i++) {
|
for (var i = 0; i < streamItems.length; i++) {
|
||||||
streamPostsIDs.push(parseInt(streamItems.eq(i).attr('data-id')));
|
streamPostsIDs.push(parseInt(streamItems.eq(i).attr('data-id')));
|
||||||
@ -91,6 +95,7 @@ function processDmConversation(stream, peerAlias, posts) {
|
|||||||
for (var i = 0; i < posts[peerAlias].length; i++) {
|
for (var i = 0; i < posts[peerAlias].length; i++) {
|
||||||
if (streamPostsIDs.indexOf(posts[peerAlias][i].id) === -1) {
|
if (streamPostsIDs.indexOf(posts[peerAlias][i].id) === -1) {
|
||||||
var lastPostID = posts[peerAlias][i].id;
|
var lastPostID = posts[peerAlias][i].id;
|
||||||
|
newPosts++;
|
||||||
postToElemDM(posts[peerAlias][i], defaultScreenName, peerAlias)
|
postToElemDM(posts[peerAlias][i], defaultScreenName, peerAlias)
|
||||||
.attr('data-id', lastPostID)
|
.attr('data-id', lastPostID)
|
||||||
.appendTo(stream)
|
.appendTo(stream)
|
||||||
@ -100,8 +105,39 @@ function processDmConversation(stream, peerAlias, posts) {
|
|||||||
}
|
}
|
||||||
$.MAL.dmChatListLoaded(stream);
|
$.MAL.dmChatListLoaded(stream);
|
||||||
}
|
}
|
||||||
if (typeof lastPostID !== 'undefined')
|
|
||||||
|
if (newPosts) {
|
||||||
resetNewDMsCountForUser(peerAlias, lastPostID);
|
resetNewDMsCountForUser(peerAlias, lastPostID);
|
||||||
|
|
||||||
|
if (getHashOfMinimizedModalWithElem(stream)) {
|
||||||
|
$.MAL.soundNotifyDM();
|
||||||
|
_newDMsPerUser[peerAlias] += newPosts;
|
||||||
|
if (peerAlias[0] === '*')
|
||||||
|
$.MAL.updateNewGroupDMsUI(getNewGroupDMsCount());
|
||||||
|
else
|
||||||
|
$.MAL.updateNewDMsUI(getNewDMsCount());
|
||||||
|
|
||||||
|
if (!$.hasOwnProperty('mobile') && $.Options.showDesktopNotifDMs.val === 'enable')
|
||||||
|
$.MAL.showDesktopNotification({
|
||||||
|
body: peerAlias[0] === '*' ?
|
||||||
|
polyglot.t('You got') + ' ' + polyglot.t('new_group_messages', newPosts) + '.'
|
||||||
|
: polyglot.t('You got') + ' ' + polyglot.t('new_direct_messages', newPosts) + '.',
|
||||||
|
tag: 'twister_notification_new_DMs',
|
||||||
|
timeout: $.Options.showDesktopNotifDMsTimer.val,
|
||||||
|
funcClick: (function() {
|
||||||
|
focusModalWithElement(this.postboard,
|
||||||
|
function (peerAlias) {
|
||||||
|
_newDMsPerUser[peerAlias] = 0;
|
||||||
|
if (peerAlias[0] === '*')
|
||||||
|
$.MAL.updateNewGroupDMsUI(getNewGroupDMsCount());
|
||||||
|
else
|
||||||
|
$.MAL.updateNewDMsUI(getNewDMsCount());
|
||||||
|
}, this.peerAlias);
|
||||||
|
}).bind({postboard: stream, peerAlias: peerAlias})
|
||||||
|
});
|
||||||
|
// TODO here we need to set new DMs counter on minimized modal button
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function directMsgSubmit(e) {
|
function directMsgSubmit(e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user