diff --git a/QvitterPlugin.php b/QvitterPlugin.php index d87dce5..3b4ec6c 100644 --- a/QvitterPlugin.php +++ b/QvitterPlugin.php @@ -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]); } } } diff --git a/actions/apiqvitterallfollowing.php b/actions/apiqvitterallfollowing.php index 9cef1bc..9822f62 100644 --- a/actions/apiqvitterallfollowing.php +++ b/actions/apiqvitterallfollowing.php @@ -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; diff --git a/actions/apiqvitterstatusesupdate.php b/actions/apiqvitterstatusesupdate.php index b23eb13..a0fa673 100644 --- a/actions/apiqvitterstatusesupdate.php +++ b/actions/apiqvitterstatusesupdate.php @@ -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); diff --git a/css/qvitter.css b/css/qvitter.css index 95422a2..afff8ab 100644 --- a/css/qvitter.css +++ b/css/qvitter.css @@ -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; diff --git a/js/qvitter.js b/js/qvitter.js index 9e118da..6d906be 100644 --- a/js/qvitter.js +++ b/js/qvitter.js @@ -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); + } } } });