Comments (6)
@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.
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.
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.
@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:
twitter-clone/src/lib/context/auth-context.tsx
Lines 70 to 74 in c6bf6fb
Good:
const randomUserSnapshot = await getDocs(
query(usersCollection, where('username', '==', randomUsername))
);
if (randomUserSnapshot.empty) available = true;
Does it make sense now?
from twitter-clone.
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.
Fixed in #40
from twitter-clone.
Related Issues (20)
- Cannot read properties of undefined (reading 'createdBy') HOT 9
- Selfhost HOT 4
- Can't upload .png HOT 1
- Localhost When Logging In HOT 7
- Running to xampp page HOT 8
- Unhandled Runtime Error FirebaseError: Failed to get document because the client is offline. HOT 1
- Error: HTTP Error: 403, The caller does not have permission HOT 1
- verification HOT 1
- respond to me on discord - itsmedxmon
- not letting me sign in
- where is the sign in page code & the css? i gotta edit it
- Gifs and Verified user HOT 1
- I love you - I have a request HOT 1
- [Function request] some suggestions HOT 10
- Images should not be indexed on alt, but rather unique id HOT 6
- Trying to implement a permissionless home and user profile page HOT 1
- Why both user/totalTweets and user/stats/stats/tweets.length ? HOT 1
- = "1" ]; then
- [FEATURE] Add location to Tweets
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from twitter-clone.