We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
const app = initializeApp(firebaseConfig); const db = getFirestore(app); const twits = collection(db, "devits");
const mapUserFromFirebaseAuthToUser = (user) => { const { displayName, email, photoURL, uid } = user
return { avatar: photoURL, username: displayName, email, uid, } }
export const onAuthStateChanged = (onChange) => { return getAuth(app).onAuthStateChanged((user) => { const normalizedUser = user ? mapUserFromFirebaseAuthToUser(user) : null onChange(normalizedUser) }) }
export const loginWithGithub = () => { const provider = new GithubAuthProvider(); const auth = getAuth(); return signInWithPopup(auth, provider); };
export const addDevit = ({ avatar, content, img, userId, userName }) => { return addDoc((twits), { avatar, content, img, userId, userName, createdAt: Timestamp.fromDate(new Date()), likesCount: 0, sharedCount: 0, }); }
export const fetchLatestDevits = async () => {
const q = query(twits, orderBy("createdAt", "desc")); const querySnapshot = getDocs(q);
return (await querySnapshot.then(({ docs }) => { return docs.map((doc) => { const data = doc.data() const id = doc.id const { createdAt } = data
return { ...data, id, createdAt: +createdAt.toDate(), } })
}));
}
export const uploadImage = (file) => { const ref = getStorage(app).ref(images/${file.name}) const task = ref.put(file) return task }
images/${file.name}
The text was updated successfully, but these errors were encountered:
No branches or pull requests
const app = initializeApp(firebaseConfig);
const db = getFirestore(app);
const twits = collection(db, "devits");
const mapUserFromFirebaseAuthToUser = (user) => {
const { displayName, email, photoURL, uid } = user
return {
avatar: photoURL,
username: displayName,
email,
uid,
}
}
export const onAuthStateChanged = (onChange) => {
return getAuth(app).onAuthStateChanged((user) => {
const normalizedUser = user ? mapUserFromFirebaseAuthToUser(user) : null
onChange(normalizedUser)
})
}
export const loginWithGithub = () => {
const provider = new GithubAuthProvider();
const auth = getAuth();
return signInWithPopup(auth, provider);
};
export const addDevit = ({ avatar, content, img, userId, userName }) => {
return addDoc((twits), {
avatar,
content,
img,
userId,
userName,
createdAt: Timestamp.fromDate(new Date()),
likesCount: 0,
sharedCount: 0,
});
}
export const fetchLatestDevits = async () => {
const q = query(twits, orderBy("createdAt", "desc"));
const querySnapshot = getDocs(q);
return (await querySnapshot.then(({ docs }) => {
return docs.map((doc) => {
const data = doc.data()
const id = doc.id
const { createdAt } = data
}));
}
export const uploadImage = (file) => {
const ref = getStorage(app).ref(
images/${file.name}
)const task = ref.put(file)
return task
}
The text was updated successfully, but these errors were encountered: