diff --git a/actions/apiqvitterallfollowing.php b/actions/apiqvitterallfollowing.php index 9822f62..ff76e8b 100644 --- a/actions/apiqvitterallfollowing.php +++ b/actions/apiqvitterallfollowing.php @@ -49,6 +49,7 @@ class ApiQvitterAllFollowingAction extends ApiBareAuthAction var $profiles = null; var $users_stripped = null; var $groups_stripped = null; + var $blocks = null; /** * Take arguments for running @@ -73,6 +74,7 @@ class ApiQvitterAllFollowingAction extends ApiBareAuthAction $this->profiles = $this->getProfiles(); $this->groups = $this->getGroups(); + $this->blocks = QvitterBlocked::getBlockedIDs($this->target->id,0,10000); // profiles: only keep id, name, nickname and avatar URL @@ -104,7 +106,7 @@ class ApiQvitterAllFollowingAction extends ApiBareAuthAction $this_group[3] = false; } $this->groups_stripped[$user_group->id] = $this_group; - } + } return true; } @@ -122,7 +124,7 @@ class ApiQvitterAllFollowingAction extends ApiBareAuthAction $this->initDocument('json'); - $this->showJsonObjects(array('users'=>$this->users_stripped,'groups'=>$this->groups_stripped)); + $this->showJsonObjects(array('users'=>$this->users_stripped,'groups'=>$this->groups_stripped,'blocks'=>$this->blocks)); $this->endDocument('json'); } diff --git a/classes/QvitterBlocked.php b/classes/QvitterBlocked.php index 0affb1c..7b8b7db 100644 --- a/classes/QvitterBlocked.php +++ b/classes/QvitterBlocked.php @@ -53,7 +53,7 @@ class QvitterBlocked extends Profile_block } - private static function getBlockedIDs($profile_id, $offset, $limit) + public static function getBlockedIDs($profile_id, $offset, $limit) { $cacheKey = 'qvitterblocked:'.$profile_id; diff --git a/css/qvitter.css b/css/qvitter.css index cfcb5d2..5a6d308 100644 --- a/css/qvitter.css +++ b/css/qvitter.css @@ -1936,6 +1936,33 @@ body.rtl .queet.rtl .expanded-content { color:#999999; } +.stream-item:not(.expanded).profile-blocked-by-me { + height:15px; + overflow:hidden; + } +.stream-item:not(.expanded).profile-blocked-by-me .queet::before { + display: block; + position: absolute; + left:0; + top:0; + height:15px; + width:100%; + background-color: #fff; + content: '\f071'; + font-family:fontAwesome; + color:#ddd; + font-size:10px; + line-height:15px; + text-align: right; + padding-right: 5px; + z-index: 100; + border-bottom:1px solid #ddd; + box-sizing: border-box; + } +.stream-item:not(.expanded).profile-blocked-by-me:hover .queet::before { + background-color: #f5f5f5; + } + /* only show activity notices if they are conversation starters we never need to see these, but sometimes someone replies to an activity notice, and then it can be good to know what the diff --git a/js/ajax-functions.js b/js/ajax-functions.js index b1b4035..fdd6fe7 100644 --- a/js/ajax-functions.js +++ b/js/ajax-functions.js @@ -204,6 +204,69 @@ function helloAPI(callback) { } +/* · + · + · Get all people we follow, all groups we're in and everyone we've blocked + · Store in global objects + · + · @param callback: function to invoke when done + · + · · · · · · · · · · · · · */ + +function getAllFollowsMembershipsAndBlocks(callback) { + + if(window.loggedIn === false) { + return; + } + + window.following = new Object(); + window.groupMemberships = new Object(); + window.groupNicknamesAndLocalAliases = new Array(); + window.allBlocking = new Array(); + + getFromAPI('qvitter/allfollowing/' + window.loggedIn.screen_name + '.json',function(data){ + + if(data.users) { + $.each(data.users,function(k,v){ + if(v[2] === false) { var avatar = window.defaultAvatarStreamSize; } + else { var avatar = v[2]; } + if(v[3]) { + // extract server base url + v[3] = v[3].substring(v[3].indexOf('://')+3,v[3].lastIndexOf(v[1])-1); + } + v[0] = v[0] || v[1]; // if name is null we go with username there too + window.following[k] = { 'id': k,'name': v[0], 'username': v[1],'avatar': avatar, 'url':v[3] }; + }); + } + + if(data.groups) { + $.each(data.groups,function(k,v){ + if(v[2] === false || v[2] === null) { var avatar = window.defaultAvatarStreamSize; } + else { var avatar = v[2]; } + if(v[3]) { + // extract server base url + v[3] = v[3].substring(v[3].indexOf('://')+3); + v[3] = v[3].substring(0, v[3].indexOf('/')); + } + v[0] = v[0] || v[1]; // if name is null we go with username there too + window.groupMemberships[k] = { 'id': k,'name': v[0], 'username': v[1],'avatar': avatar, 'url':v[3] }; + window.groupNicknamesAndLocalAliases[k] = v[1]; + }); + } + + if(data.blocks) { + window.allBlocking = data.blocks; + } + + if(typeof callback == 'function') { + callback(); + } + }); + } + + + + /* · · · Get user nickname by user id diff --git a/js/dom-functions.js b/js/dom-functions.js index be87621..9b2a27f 100644 --- a/js/dom-functions.js +++ b/js/dom-functions.js @@ -1839,6 +1839,15 @@ function addToFeed(feed, after, extraClasses, isReply) { function buildQueetHtml(obj, idInStream, extraClassesThisRun, requeeted_by, isConversation) { + // if we've blocked this user, but it has slipped through anyway + $.each(window.allBlocking,function(){ + if(this == obj.user.id){ + extraClassesThisRun = extraClassesThisRun + ' profile-blocked-by-me'; + return false; // break + } + }); + + // if we have the full html for a truncated notice cached in localstorage, we use that var cacheData = localStorageObjectCache_GET('fullQueetHtml',obj.id); if(cacheData) { diff --git a/js/qvitter.js b/js/qvitter.js index 5d46428..fd630bc 100644 --- a/js/qvitter.js +++ b/js/qvitter.js @@ -867,44 +867,11 @@ function doLogin(streamObjectToSet) { $('#qvitter-notice').show(); $('#user-screen-name, #user-avatar, #user-name').attr('data-tooltip', window.sL.viewMyProfilePage); - // get all users i'm following for autosuggestion - window.following = new Object(); - window.groupMemberships = new Object(); - window.groupNicknamesAndLocalAliases = new Array(); - - getFromAPI('qvitter/allfollowing/' + window.loggedIn.screen_name + '.json',function(data){ - - if(data.users) { - $.each(data.users,function(k,v){ - if(v[2] === false) { var avatar = window.defaultAvatarStreamSize; } - else { var avatar = v[2]; } - if(v[3]) { - // extract server base url - v[3] = v[3].substring(v[3].indexOf('://')+3,v[3].lastIndexOf(v[1])-1); - } - v[0] = v[0] || v[1]; // if name is null we go with username there too - window.following[k] = { 'id': k,'name': v[0], 'username': v[1],'avatar': avatar, 'url':v[3] }; - }); - } - - if(data.groups) { - $.each(data.groups,function(k,v){ - if(v[2] === false || v[2] === null) { var avatar = window.defaultAvatarStreamSize; } - else { var avatar = v[2]; } - if(v[3]) { - // extract server base url - v[3] = v[3].substring(v[3].indexOf('://')+3); - v[3] = v[3].substring(0, v[3].indexOf('/')); - } - v[0] = v[0] || v[1]; // if name is null we go with username there too - window.groupMemberships[k] = { 'id': k,'name': v[0], 'username': v[1],'avatar': avatar, 'url':v[3] }; - window.groupNicknamesAndLocalAliases[k] = v[1]; - }); - } + // get everyone we follow, block and our memberships and stor in global objects + getAllFollowsMembershipsAndBlocks(function(){ // do this now not to stall slow computers, also we know of group memberships to highlight now cacheSyntaxHighlighting(); - cacheSyntaxHighlightingGroups(); // we might have cached text for the queet box // (we need to get the mentions suggestions and cache the syntax highlighting before doing this)