Browse Source

experimental post delivery indicator. requires twister-core update.

master
Miguel Freitas 10 years ago
parent
commit
0ef54f463e
  1. 1
      home.html
  2. 15
      js/twister_formatpost.js
  3. 9
      js/twister_io.js

1
home.html

@ -309,6 +309,7 @@
<div class="post-info"> <div class="post-info">
<a href="#" class="post-info-name open-profile-modal"></a> <a href="#" class="post-info-name open-profile-modal"></a>
<span class="post-info-tag"></span> <span class="post-info-tag"></span>
<span class="post-info-sent"></span>
<a class="post-info-time"></a> <a class="post-info-time"></a>
</div> </div>
<p class="post-text"></p> <p class="post-text"></p>

15
js/twister_formatpost.js

@ -86,6 +86,9 @@ function postToElem( post, kind, promoted ) {
postInfoName.text(n).attr('href', $.MAL.userUrl(n)); postInfoName.text(n).attr('href', $.MAL.userUrl(n));
getFullname( n, postInfoName ); getFullname( n, postInfoName );
//elem.find('.post-info-tag').text("@" + n); //elem.find('.post-info-tag').text("@" + n);
if( n === defaultScreenName ) {
setPostInfoSent(n,k,elem.find('.post-info-sent'));
}
getAvatar( n, elem.find('.avatar') ); getAvatar( n, elem.find('.avatar') );
elem.find('.post-info-time').text(timeGmtToText(t)).attr('title', timeSincePost(t)); elem.find('.post-info-time').text(timeGmtToText(t)).attr('title', timeSincePost(t));
@ -141,6 +144,18 @@ function postToElem( post, kind, promoted ) {
return elem; return elem;
} }
function setPostInfoSent(n, k, item) {
getPostMaxAvailability(n,k,
function(args,count) {
if( count >= 3 ) { // assume 3 peers (me + 2) is enough for "sent"
args.item.text("\u2713"); // check mark
} else {
args.item.text("\u231B"); // hour glass
setTimeout(setPostInfoSent,2000,n,k,item);
}
}, {n:n,k:k,item:item});
}
// format dmdata (returned by getdirectmsgs) to display in "snippet" per user list // format dmdata (returned by getdirectmsgs) to display in "snippet" per user list
function dmDataToSnippetItem(dmData, remoteUser) { function dmDataToSnippetItem(dmData, remoteUser) {
var dmItem = $("#dm-snippet-template").clone(true); var dmItem = $("#dm-snippet-template").clone(true);

9
js/twister_io.js

@ -398,6 +398,15 @@ function getPostsCount( username, item ) {
}, {username:username,item:item} ); }, {username:username,item:item} );
} }
function getPostMaxAvailability(username, k, cbFunc, cbArg) {
twisterRpc("getpiecemaxseen", [username,k],
function(args, ret) {
args.cbFunc(args.cbArg, ret);
}, {cbFunc:cbFunc, cbArg:cbArg},
function(args, ret) {
console.log("getPostAvailability error");
}, {cbFunc:cbFunc, cbArg:cbArg});
}
function checkPubkeyExists(username, cbFunc, cbArg) { function checkPubkeyExists(username, cbFunc, cbArg) {
// pubkey is checked in block chain db. // pubkey is checked in block chain db.

Loading…
Cancel
Save