mirror of
https://github.com/twisterarmy/twister-html.git
synced 2025-01-13 16:37:52 +00:00
very crude initial support to display group chat as standard direct messages.
still a lot to do: using the "from" field from group messages to display who sent each message, options to invite, display members, change group description, leave etc.
This commit is contained in:
parent
6c4ea6544a
commit
cc1c5e5d11
@ -8,6 +8,9 @@ function requestDMsnippetList(dmThreadList) {
|
||||
for( var i = 0; i < followingUsers.length; i++ ) {
|
||||
followList.push({username:followingUsers[i]});
|
||||
}
|
||||
for( var i = 0; i < groupChatAliases.length; i++ ) {
|
||||
followList.push({username:groupChatAliases[i]});
|
||||
}
|
||||
|
||||
twisterRpc("getdirectmsgs", [defaultScreenName, 1, followList],
|
||||
function(req, ret) {processDMsnippet(ret, dmThreadList);}, dmThreadList,
|
||||
@ -43,6 +46,9 @@ function processDMsnippet(dmUsers, dmThreadList) {
|
||||
}
|
||||
|
||||
function openDmConversation(dm_screenname, dmTitleName, dmConversation) {
|
||||
if( dm_screenname.length && dm_screenname[0] === '*' )
|
||||
getGroupChatName( dm_screenname, dmTitleName );
|
||||
else
|
||||
getFullname( dm_screenname, dmTitleName );
|
||||
dmConversation.attr("data-dm-screen-name", dm_screenname);
|
||||
|
||||
@ -116,7 +122,7 @@ function newDirectMsg(msg, dm_screenname) {
|
||||
var paramsOrig = [defaultScreenName, lastPostId + 1, dm_screenname, msg]
|
||||
var paramsOpt = paramsOrig
|
||||
var copySelf = ($.Options.getDMCopySelfOpt() === 'enable')
|
||||
if( copySelf ) {
|
||||
if( copySelf && dm_screenname[0] !== '*' ) {
|
||||
paramsOpt = paramsOrig.concat(true)
|
||||
}
|
||||
|
||||
|
@ -153,6 +153,9 @@ function dmDataToSnippetItem(dmData, remoteUser) {
|
||||
dmItem.find("a.post-info-name").attr("href", $.MAL.userUrl(remoteUser));
|
||||
dmItem.find("a.dm-chat-link").attr("href", $.MAL.dmchatUrl(remoteUser));
|
||||
getAvatar( remoteUser, dmItem.find(".post-photo").find("img") );
|
||||
if( remoteUser.length && remoteUser[0] === '*' )
|
||||
getGroupChatName( remoteUser, dmItem.find("a.post-info-name") );
|
||||
else
|
||||
getFullname( remoteUser, dmItem.find("a.post-info-name") );
|
||||
dmItem.find(".post-text").html(escapeHtmlEntities(dmData.text));
|
||||
dmItem.find(".post-info-time").text(timeGmtToText(dmData.time));
|
||||
|
@ -296,6 +296,16 @@ function getWebpage( username, item ){
|
||||
}, {item:item} );
|
||||
}
|
||||
|
||||
function getGroupChatName( groupalias, item ){
|
||||
twisterRpc("getgroupinfo", [groupalias],
|
||||
function(args, ret) {
|
||||
args.item.text(ret["description"]);
|
||||
}, {item:item},
|
||||
function(args, ret) {
|
||||
args.item.text("getgroupinfo error");
|
||||
}, {item:item});
|
||||
}
|
||||
|
||||
// we must cache avatar results to disk to lower bandwidth on
|
||||
// other peers. dht server limits udp rate so requesting too much
|
||||
// data will only cause new requests to fail.
|
||||
|
@ -13,6 +13,7 @@ var _lastLocalMentionId = -1;
|
||||
var PURGE_OLD_MENTIONS_TIMEOUT = 3600 * 24 * 30; // one month
|
||||
var _newMentionsUpdated = false;
|
||||
var _newDMsUpdated = false;
|
||||
var groupChatAliases = []
|
||||
|
||||
// process a mention received to check if it is really new
|
||||
function processMention(user, mentionTime, data) {
|
||||
@ -176,6 +177,9 @@ function requestDMsCount() {
|
||||
for( var i = 0; i < followingUsers.length; i++ ) {
|
||||
followList.push({username:followingUsers[i]});
|
||||
}
|
||||
for( var i = 0; i < groupChatAliases.length; i++ ) {
|
||||
followList.push({username:groupChatAliases[i]});
|
||||
}
|
||||
|
||||
twisterRpc("getdirectmsgs", [defaultScreenName, 1, followList],
|
||||
function(req, dmUsers) {
|
||||
@ -221,10 +225,21 @@ function resetNewDMsCountForUser(user, lastId) {
|
||||
$.MAL.updateNewDMsUI(getNewDMsCount());
|
||||
}
|
||||
|
||||
function updateGroupList() {
|
||||
twisterRpc("listgroups", [],
|
||||
function(req, ret) {groupChatAliases=ret;}, null,
|
||||
function(req, ret) {console.log("twisterd >= 0.9.30 required for listgroups");}, null);
|
||||
}
|
||||
|
||||
function initDMsCount() {
|
||||
loadDMsFromStorage();
|
||||
$.MAL.updateNewDMsUI(getNewDMsCount());
|
||||
requestDMsCount();
|
||||
|
||||
//quick hack to obtain list of group chat aliases
|
||||
updateGroupList();
|
||||
setInterval("updateGroupList();", 60000);
|
||||
|
||||
setTimeout("requestDMsCount();", 200);
|
||||
//polling not needed: processNewPostsConfirmation will call requestDMsCount.
|
||||
//setInterval("requestDMsCount()", 5000);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user