Code Monkey home page Code Monkey logo

Comments (6)

ccrsxx avatar ccrsxx commented on May 31, 2024 2

@stanbar Good catch, that's definitely a bug. I didn't realize that the id for the user on firestore is using guid instead of username.

Thanks @Ketchupchh for the fix on the PR.

from twitter-clone.

stanbar avatar stanbar commented on May 31, 2024 1

@Ketchupchh

It's not a matter of preference. It's a bug that causes two users to have the same username.

Actually I found another problem with the file id. It's present in your PR as well #42

from twitter-clone.

Ketchupchh avatar Ketchupchh commented on May 31, 2024

I'm not sure if I get exactly what you're asking (I have not been to sleep in a long time) but the code you're referencing is to check if there's a user in the database that already goes by that username. They're shouldn't be duplicate usernames in the database. Correct me if I didn't fully understand your question, sorry.

from twitter-clone.

stanbar avatar stanbar commented on May 31, 2024

@Ketchupchh Haha, no problem 😄

My point is that you are checking username uniqueness on the document's key level. Instead you should check it on the document's username field level.

Wrong:

const randomUserSnapshot = await getDoc(
doc(usersCollection, randomUsername)
);
if (!randomUserSnapshot.exists()) available = true;

Good:

      const randomUserSnapshot = await getDocs(
        query(usersCollection, where('username', '==', randomUsername))
      );
      if (randomUserSnapshot.empty) available = true;

Does it make sense now?

from twitter-clone.

Ketchupchh avatar Ketchupchh commented on May 31, 2024

Oh I get what you're saying now. I definitely would've done the latter. I'm quite new to Firestore but I think it probably just boils down to preference atp no? Unless @ccrsxx had reason for doing it the way he did(?)

I know he's a busy fella so if he wants to make the change I'm more than happy to add it to my pull request.

from twitter-clone.

ccrsxx avatar ccrsxx commented on May 31, 2024

Fixed in #40

from twitter-clone.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.