Skip to content

Comment bug handle_name (user_id) gets mixed with other comments #5

@platypus36

Description

@platypus36

This comment bug occurs when we have multiple users commenting on a post

I think the root of the problem is this lines of code:
` private void getHandleName(final ViewHolder viewHolder) {
DatabaseReference reference = FirebaseDatabase.getInstance().getReference();
Log.d(TAG, "getHandleName: checking comment userID" + viewHolder.comment.getUser_id());
Query query;
query = reference
.child("data")
.child("-Kxzyb5JsUPhsMQAb84X")
.child("users")
.orderByChild("user_id")
.equalTo(viewHolder.comment.getUser_id());

    query.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            for (DataSnapshot singleSnapshot : dataSnapshot.getChildren()) {
                viewHolder.handleName.clearComposingText();
                viewHolder.handleName.setText(singleSnapshot.getValue(User.class).getHandlename());
            }
        }
        @Override
        public void onCancelled(DatabaseError databaseError) {

        }
    });
}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions