add new group memberships to suggestion array, and delete when leaving group. also use group's proper id not group's profile id
This commit is contained in:
parent
d9c978e5fa
commit
721cb83201
|
@ -933,21 +933,21 @@ class QvitterPlugin extends Plugin {
|
|||
if(isset($_POST['post_to_groups'])) {
|
||||
$correct_group_mentions = explode(':',$_POST['post_to_groups']);
|
||||
foreach($correct_group_mentions as $group_id) {
|
||||
$correct_group_mentions_profiles[] = Profile::getKV('id',$group_id);
|
||||
$correct_groups[] = User_group::getKV('id',$group_id);
|
||||
}
|
||||
|
||||
// loop through the groups guessed by gnu social's common_find_mentions() and correct them
|
||||
foreach($mentions as $mention_array_id=>$mention) {
|
||||
foreach($correct_group_mentions_profiles as $correct_group_array_id=>$correct_group_profile) {
|
||||
if($mention['mentioned'][0]->nickname == $correct_group_profile->nickname
|
||||
foreach($correct_groups as $correct_groups_array_id=>$correct_group) {
|
||||
if($mention['mentioned'][0]->nickname == $correct_group->nickname
|
||||
&& !isset($mentions[$mention_array_id]['corrected'])) {
|
||||
$mentions[$mention_array_id]['mentioned'][0] = $correct_group_profile;
|
||||
$user_group = User_group::getKV('profile_id',$correct_group_profile->id);
|
||||
$mentions[$mention_array_id]['url'] = $user_group->permalink();
|
||||
$mentions[$mention_array_id]['title'] = $user_group->getFancyName();
|
||||
$user_group_profile = Profile::getKV('id',$correct_group->profile_id);
|
||||
$mentions[$mention_array_id]['mentioned'][0] = $user_group_profile;
|
||||
$mentions[$mention_array_id]['url'] = $correct_group->permalink();
|
||||
$mentions[$mention_array_id]['title'] = $correct_group->getFancyName();
|
||||
$mentions[$mention_array_id]['corrected'] = true;
|
||||
// now we've used this
|
||||
unset($correct_group_mentions_profiles[$correct_group_array_id]);
|
||||
unset($correct_groups[$correct_groups_array_id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ class ApiQvitterAllFollowingAction extends ApiBareAuthAction
|
|||
else {
|
||||
$this_group[3] = false;
|
||||
}
|
||||
$this->groups_stripped[$p->id] = $this_group;
|
||||
$this->groups_stripped[$user_group->id] = $this_group;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -283,11 +283,7 @@ class ApiQvitterStatusesUpdateAction extends ApiAuthAction
|
|||
// groups
|
||||
$group_ids = Array();
|
||||
if(strlen($this->post_to_groups)>0) {
|
||||
$groups_profile_ids = explode(':',$this->post_to_groups);
|
||||
foreach($groups_profile_ids as $group_profile_id) {
|
||||
$user_group = User_group::getKV('profile_id',$group_profile_id);
|
||||
$group_ids[] = $user_group->id;
|
||||
}
|
||||
$group_ids = explode(':',$this->post_to_groups);
|
||||
}
|
||||
|
||||
$options = array('reply_to' => $reply_to, 'groups' => $group_ids);
|
||||
|
|
|
@ -3979,7 +3979,7 @@ background:rgba(0,0,0,0.2);
|
|||
.modal-body .inline-reply-queetbox {
|
||||
padding-left:12px;
|
||||
margin-top: -1px;
|
||||
overflow: hidden;
|
||||
/* don't use overflow hidden here! mentions-suggestions will be cut then */
|
||||
}
|
||||
body.rtl .modal-body .inline-reply-queetbox {
|
||||
direction:rtl;
|
||||
|
|
|
@ -872,11 +872,29 @@ $('body').on('click','.member-button',function(event){
|
|||
$(this_element).addClass('member');
|
||||
$('.profile-card .member-stats strong').html(parseInt($('.profile-card .member-stats strong').html(),10)+1);
|
||||
$('#user-groups strong').html(parseInt($('#user-groups strong').html(),10)+1);
|
||||
// add group to mention suggestion array
|
||||
if(data.homepage_logo === null) {
|
||||
data.homepage_logo = window.defaultAvatarStreamSize;
|
||||
}
|
||||
var groupmembershipObject = { avatar:data.homepage_logo, id:data.id, name:data.fullname, url:data.url, username:data.nickname };
|
||||
window.groupMemberships.push(groupmembershipObject);
|
||||
}
|
||||
else if(data.member === false) {
|
||||
$(this_element).removeClass('member');
|
||||
$('.profile-card .member-stats strong').html(parseInt($('.profile-card .member-stats strong').html(),10)-1);
|
||||
$('#user-groups strong').html(parseInt($('#user-groups strong').html(),10)-1);
|
||||
|
||||
// remove group from mention suggestion array, if it's there
|
||||
var groupToRemove = false;
|
||||
$.each(window.groupMemberships,function(k,v) {
|
||||
if(v.id == data.id) {
|
||||
groupToRemove = k;
|
||||
}
|
||||
});
|
||||
if(groupToRemove) {
|
||||
console.log('remove at' + groupToRemove);
|
||||
window.groupMemberships.splice(groupToRemove,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user