semi-hide notices form profiles we're blocking

This commit is contained in:
Hannes Mannerheim 2015-11-18 16:38:19 +01:00
parent 25447c2527
commit 14ae286aeb
6 changed files with 106 additions and 38 deletions

View File

@ -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');
}

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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) {

View File

@ -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)