blonsky95 / DigiCoachAndroid

0 stars 0 forks source link

1.0.11 - Friends - create a social tab or in profile #66

Closed blonsky95 closed 4 years ago

blonsky95 commented 4 years ago

Simply display a list of added friends (UI), also have to build a database something, e.g. User document has a friends collection - the documents in this collection are friends, there is a state to know if requested, but when the other one opens it and accepts it changes so you good now, friend should display.

blonsky95 commented 4 years ago

Probs have to create an entity for friends, and contain as properties: Username

In profile and do another fragment would be cool

displays list of friends + button to add friend - cant really click them or do anything when add friend you put username and it sends request

the friend icon on profile is like calendar and exercise where number changes when it receives friend request, then on firebase it will be similar to transfer_exercises - there will be a friends tab or something with all the states of requests and sender/receiver fields - transfer package inside

blonsky95 commented 4 years ago

Do this one, bear in mind searching bars are going to be implemented more than once so try and do something scalable/reusable, not just a working version

blonsky95 commented 4 years ago

Friends UI is almost done + Room

Next - setup UI to receive new requests - handle text

Then for firebase stuff - each user has a friends collection, all friends with state granted are friends that should appear

blonsky95 commented 4 years ago

requests is working but a few things to address:

  1. check if user doesn't exist, or if you already have him as a friend
blonsky95 commented 4 years ago

OK SO everything is done and yet to mass test but working basics - not the search friends tab, thats another ticket

So the way its working is each user has f_requests_out = info on requests it sends f_requests_in = info on requests that come in

each request has a sender, a receiver, a state (SENT, REJECTED, ACCEPTED) requests in f_requests_in also contain a senderId so the receiver has a quick reference to update the field of the senders request_in (explained below):

user A sends to user B, it creates a request on both sender _out and receiver _in with state SENT when user B accepts, it inserts friend and updates the sender_out to ACCEPTED and receiver_in to ACCEPTED, then user B also inserts. To make this work there is 2 snapshot listeners:

There is a listener for requests_in with state SENT There is a listener for requests_out with state ACCEPTED - so when receiver accepts this gets triggered so the sending user inserts friend too. It also updates _out from accepted to accepted-solved

Before sending request, and before inserting it checks if its contained. Only weird thing, is the listener for requests_out, has a little force pause of 3s between inserting and updating from accepted to accepted-solved - unsure why