For finding whether a user profile is already saved or not, you are using a bad approach. You are fetching the entire collection and then searching for the required email id locally. Don't you think that's bad? What if tomorrow you have 1M users, will you fetch data of all and query locally?
Instead you should use Firestore Query. Read this official doc carefully to understand how querying works. For your query, you can write code like this db.collection("users").whereEqualTo("email", "abc@x.yz").limit(1). This way, querying will now be performed on the cloud and we receive only the doc we need locally.
https://github.com/Code3six/FaangX/blob/0b4924d8cfe8832135b4a60f74daa7917b26683f/app/src/main/java/com/example/faangx/presentation/viewmodel/SharedViewModel.kt#L99-L112
For finding whether a user profile is already saved or not, you are using a bad approach. You are fetching the entire collection and then searching for the required email id locally. Don't you think that's bad? What if tomorrow you have 1M users, will you fetch data of all and query locally?
Instead you should use Firestore Query. Read this official doc carefully to understand how querying works. For your query, you can write code like this
db.collection("users").whereEqualTo("email", "abc@x.yz").limit(1)
. This way, querying will now be performed on the cloud and we receive only the doc we need locally.