Skip to content

Commit

Permalink
only group owner or manager can mention all
Browse files Browse the repository at this point in the history
  • Loading branch information
imndx committed Oct 12, 2019
1 parent 62e2dfe commit 5a04111
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@
import cn.wildfire.chat.kit.contact.model.UIUserInfo;
import cn.wildfire.chat.kit.group.GroupViewModel;
import cn.wildfirechat.model.GroupInfo;
import cn.wildfirechat.model.GroupMember;
import cn.wildfirechat.remote.ChatManager;

public class MentionGroupMemberFragment extends BaseUserListFragment {
private GroupInfo groupInfo;
private GroupMember groupMember;
private GroupViewModel groupViewModel;

public static MentionGroupMemberFragment newInstance(GroupInfo groupInfo) {
Bundle args = new Bundle();
Expand All @@ -29,14 +33,15 @@ public static MentionGroupMemberFragment newInstance(GroupInfo groupInfo) {
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
groupInfo = getArguments().getParcelable("groupInfo");
showQuickIndexBar(true);
groupInfo = getArguments().getParcelable("groupInfo");
groupViewModel = ViewModelProviders.of(getActivity()).get(GroupViewModel.class);
groupMember = groupViewModel.getGroupMember(groupInfo.target, ChatManager.Instance().getUserId());
}

@Override
protected void afterViews(View view) {
super.afterViews(view);
GroupViewModel groupViewModel = ViewModelProviders.of(getActivity()).get(GroupViewModel.class);
groupViewModel.getGroupMemberUIUserInfosLiveData(groupInfo.target, false).observe(this, uiUserInfos -> {
showContent();
userListAdapter.setUsers(uiUserInfos);
Expand All @@ -50,7 +55,11 @@ public UserListAdapter onCreateUserListAdapter() {

@Override
public void initHeaderViewHolders() {
addHeaderViewHolder(MentionAllHeaderViewHolder.class, new HeaderValue());
if (groupMember != null) {
if (groupMember.type == GroupMember.GroupMemberType.Manager || groupMember.type == GroupMember.GroupMemberType.Owner) {
addHeaderViewHolder(MentionAllHeaderViewHolder.class, new HeaderValue());
}
}
}

@Override
Expand Down

0 comments on commit 5a04111

Please sign in to comment.