|
|
@ -5,7 +5,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
var _groupMsgInviteToGroupQueue = []; |
|
|
|
var _groupMsgInviteToGroupQueue = []; |
|
|
|
|
|
|
|
|
|
|
|
function requestDMsnippetList(dmThreadList, forGroup) { |
|
|
|
function requestDMsnippetList(elemList, forGroup) { |
|
|
|
var followList = []; |
|
|
|
var followList = []; |
|
|
|
for (var i = 0; i < followingUsers.length; i++) |
|
|
|
for (var i = 0; i < followingUsers.length; i++) |
|
|
|
followList.push({username: followingUsers[i]}); |
|
|
|
followList.push({username: followingUsers[i]}); |
|
|
@ -13,40 +13,19 @@ function requestDMsnippetList(dmThreadList, forGroup) { |
|
|
|
followList.push({username: groupChatAliases[i]}); |
|
|
|
followList.push({username: groupChatAliases[i]}); |
|
|
|
|
|
|
|
|
|
|
|
twisterRpc('getdirectmsgs', [defaultScreenName, 1, followList], |
|
|
|
twisterRpc('getdirectmsgs', [defaultScreenName, 1, followList], |
|
|
|
function(req, ret) {processDMsnippet(ret, req.dmThreadList, req.forGroup);}, |
|
|
|
processDMsnippet, {elemList: elemList, forGroup: forGroup}, |
|
|
|
{dmThreadList: dmThreadList, forGroup: forGroup}, |
|
|
|
|
|
|
|
function(req, ret) {console.log('ajax error:' + ret);}, null |
|
|
|
function(req, ret) {console.log('ajax error:' + ret);}, null |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function processDMsnippet(dmUsers, dmThreadList, forGroup) { |
|
|
|
function processDMsnippet(req, DMs) { |
|
|
|
dmThreadList.empty(); |
|
|
|
req.elemList.empty(); |
|
|
|
|
|
|
|
|
|
|
|
for (var u in dmUsers) { |
|
|
|
for (var alias in DMs) |
|
|
|
if ((forGroup && u[0] !== '*') || (!forGroup && u[0] === '*')) |
|
|
|
if ((req.forGroup && alias[0] === '*') || (!req.forGroup && alias[0] !== '*')) |
|
|
|
continue; |
|
|
|
addToCommonDMsList(req.elemList, alias, DMs[alias][0]); |
|
|
|
|
|
|
|
|
|
|
|
// convert snipped to html and add it to date-sorted list
|
|
|
|
$.MAL.commonDMsListLoaded(); |
|
|
|
var dmItem = dmDataToSnippetItem(dmUsers[u][0], u); |
|
|
|
|
|
|
|
if (_newDMsPerUser[u] > 0) { |
|
|
|
|
|
|
|
dmItem.addClass('new') |
|
|
|
|
|
|
|
.find('.messages-qtd').text(_newDMsPerUser[u]).show(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var timeDmItem = parseInt(dmItem.attr('data-time')); |
|
|
|
|
|
|
|
var existingItems = dmThreadList.children(); |
|
|
|
|
|
|
|
for (var j = 0; j < existingItems.length; j++) { |
|
|
|
|
|
|
|
var streamItem = existingItems.eq(j); |
|
|
|
|
|
|
|
var timeExisting = streamItem.attr('data-time'); |
|
|
|
|
|
|
|
if (typeof timeExisting === 'undefined' || timeDmItem > parseInt(timeExisting)) { |
|
|
|
|
|
|
|
// this post in stream is older, so post must be inserted above
|
|
|
|
|
|
|
|
streamItem.before(dmItem); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (j === existingItems.length) |
|
|
|
|
|
|
|
dmThreadList.append(dmItem); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$.MAL.dmThreadListLoaded(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function requestDmConversationModal(postboard, peerAlias) { |
|
|
|
function requestDmConversationModal(postboard, peerAlias) { |
|
|
@ -103,7 +82,7 @@ function processDmConversation(stream, peerAlias, posts) { |
|
|
|
streamPostsIDs.push(lastPostID); |
|
|
|
streamPostsIDs.push(lastPostID); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
$.MAL.dmChatListLoaded(stream); |
|
|
|
$.MAL.dmConversationLoaded(stream); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (newPosts) { |
|
|
|
if (newPosts) { |
|
|
@ -183,7 +162,7 @@ function newDirectMsg(msg, peerAlias) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// dispara o modal de direct messages
|
|
|
|
// dispara o modal de direct messages
|
|
|
|
function directMessagesPopup() { |
|
|
|
function openCommonDMsModal() { |
|
|
|
if (!defaultScreenName) { |
|
|
|
if (!defaultScreenName) { |
|
|
|
alert(polyglot.t('You have to log in to use direct messages.')); |
|
|
|
alert(polyglot.t('You have to log in to use direct messages.')); |
|
|
|
return; |
|
|
|
return; |
|
|
@ -191,7 +170,7 @@ function directMessagesPopup() { |
|
|
|
|
|
|
|
|
|
|
|
var modal = openModal({ |
|
|
|
var modal = openModal({ |
|
|
|
classAdd: 'directMessages', |
|
|
|
classAdd: 'directMessages', |
|
|
|
content: $('.direct-messages-template').children().clone(true), |
|
|
|
content: twister.tmpl.commonDMsList.clone(true), |
|
|
|
title: polyglot.t('Direct Messages') |
|
|
|
title: polyglot.t('Direct Messages') |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -245,7 +224,7 @@ function openGroupMessagesModal(groupAlias) { |
|
|
|
if (typeof groupAlias === 'undefined') { |
|
|
|
if (typeof groupAlias === 'undefined') { |
|
|
|
var modal = openModal({ |
|
|
|
var modal = openModal({ |
|
|
|
classAdd: 'directMessages groupMessages', |
|
|
|
classAdd: 'directMessages groupMessages', |
|
|
|
content: $('.direct-messages-template').children().clone(true), |
|
|
|
content: twister.tmpl.commonDMsList.clone(true), |
|
|
|
title: polyglot.t('Group Messages') |
|
|
|
title: polyglot.t('Group Messages') |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -496,11 +475,6 @@ function initInterfaceDirectMsg() { |
|
|
|
$('.groupmessages').attr('href', '#groupmessages'); |
|
|
|
$('.groupmessages').attr('href', '#groupmessages'); |
|
|
|
$('.userMenu-groupmessages a').attr('href', '#groupmessages'); |
|
|
|
$('.userMenu-groupmessages a').attr('href', '#groupmessages'); |
|
|
|
|
|
|
|
|
|
|
|
$('#dm-snippet-template').on('click', function() { |
|
|
|
|
|
|
|
var alias = $(this).attr('data-screen-name'); |
|
|
|
|
|
|
|
window.location.hash = '#directmessages?' + (alias[0] === '*' ? 'group' : 'user') + '=' + alias; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('.dm-submit').on('click', directMsgSubmit); |
|
|
|
$('.dm-submit').on('click', directMsgSubmit); |
|
|
|
$('.direct-messages-with-user').on('click', function() { |
|
|
|
$('.direct-messages-with-user').on('click', function() { |
|
|
|
window.location.hash = '#directmessages?user=' + |
|
|
|
window.location.hash = '#directmessages?user=' + |
|
|
|