How to use the redux-firestore.getFirestore function in redux-firestore

To help you get started, we’ve selected a few redux-firestore examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sikidamjanovic / cowrite / src / Components / Posts / StoryCard.js View on Github external
getAvatar(){
        var that = this
        getFirestore().collection('users').doc(this.props.author).get()
        .then(function(doc) {
            if (doc.exists) {
                if(doc.data().photoURL !== undefined){
                    that.setState({
                        photoURL: doc.data().photoURL
                    })
                }else{
                    that.setState({
                        photoURL: null
                    })
                }
            } else {
                // doc.data() will be undefined in this case
                message.error("No such document!");
            }
        }).catch(function(error) {
github sikidamjanovic / cowrite / src / Components / Posts / StoryModalContent.js View on Github external
userLiked: true,
                    amountOfLikes: this.state.amountOfLikes + 1
                })
                getFirestore().collection('stories').doc(this.props.id).update({
                    likes: firebase.firestore.FieldValue.arrayUnion(
                        this.props.auth.displayName
                    ),
                    likeCount: firebase.firestore.FieldValue.increment(1)
                })
            }else{
                this.setState({
                    userLiked: false,
                    amountOfLikes: this.state.amountOfLikes - 1
                })
                // Delete user from posts 'likes' collection
                getFirestore().collection('stories').doc(this.props.id).update({
                    likes: firebase.firestore.FieldValue.arrayRemove(
                        this.props.auth.displayName
                    ),
                    likeCount: firebase.firestore.FieldValue.increment(-1)
                })
            }
        }else{
            message.warning('Please login or sign up to like prompts')
        } 
    }
github sikidamjanovic / cowrite / src / Store / Actions / authActions.js View on Github external
return (dispatch, getState, {getFirebase}) => {
        const firebase = getFirebase();
        const firestore = getFirestore();
        let check = false;
        let usersRef = firestore.collection('users');
        usersRef.get()
        .then(snapshot => {
            snapshot.forEach(doc => {
                if (doc.id === newUser.username) { check = true; }
            });
            if (check === false) {
                firebase.auth().createUserWithEmailAndPassword(
                    newUser.email,
                    newUser.password,
                ).then((resp) => {
                    return (
                        firestore.collection('users').doc(newUser.username).set({
                            uid: resp.user.uid,
                            displayName: newUser.username
github sikidamjanovic / cowrite / src / Components / Posts / StoryComment.js View on Github external
deleteSubmission(){
        getFirestore().collection('stories').doc(this.props.postId).collection('submissions').doc(this.props.id).delete()
        .then(function() {
            message.success('Your submission has been deleted.')
        }).catch(function(error) {
            message.error(error)
        });
    }
github sikidamjanovic / cowrite / src / Components / Posts / StoryComment.js View on Github external
getAvatar(){
        var that = this
        getFirestore().collection('users').doc(this.props.author).get()
        .then(function(doc) {
            if (doc.exists) {
                if(doc.data().photoURL !== undefined){
                    that.setState({
                        photoURL: doc.data().photoURL
                    })
                }else{
                    that.setState({
                        photoURL: null
                    })
                }
            } else {
                message.error("No such document!");
            }
        }).catch(function(error) {
            message.error("Error getting document:", error);
github sikidamjanovic / cowrite / src / Components / Posts / StoryModalContent.js View on Github external
getFirestore().collection('notifications').doc().set({
                title: this.props.title,
                notification: 'is now on chapter ' + (this.props.currentChapter + 1),
                type: 'chapter',
                id: this.props.id,
                time: now.toString(),
                date: now
            })
        }else{
            getFirestore().collection('stories').doc(this.props.id).update({
                complete: true,
                selectedChapters: firebase.firestore.FieldValue.arrayUnion(
                    topSubmission
                )
            })
            getFirestore().collection('notifications').doc().set({
                title: this.props.title,
                notification: 'has been completed',
                type: 'complete',
                id: this.props.id,
                time: now.toString(),
                date: now
            })
        }
    }
github sikidamjanovic / cowrite / src / Components / Posts / ReportModal.js View on Github external
handleReport = e => {
        var text = this.state.text
        var value = this.state.value

        if(value === null){
            message.error('Please select a type')
        }else if(text.length === 0){
            message.error('Please provide reasoning')
        }else{
            getFirestore().collection('reports').doc().set({
                postId: this.props.id,
                type: this.props.type,
                category: value,
                reason: text
            })
            this.setState({
                visible: false
            },() => {
                if(this.type === "story"){
                    message.success("Story has been reported! We'll look into it")
                }else{
                    message.success("Prompt has been reported! We'll look into it")
                }
            })
        }
    };
github sikidamjanovic / cowrite / src / Components / Profile / UserProfile.js View on Github external
getAvatar(displayName){
        var that = this
        getFirestore().collection('users').doc(displayName).get()
        .then(function(doc) {
            if (doc.exists) {
                if(doc.data().photoURL !== undefined){
                    that.setState({
                        photoURL: doc.data().photoURL
                    })
                }else{
                    that.setState({
                        photoURL: null
                    })
                }
            }
        }).catch(function(error) {
            message.error("Error getting document:", error);
        });
    }
github sikidamjanovic / cowrite / src / Components / Common / AccountDropdown.js View on Github external
getAvatar(){
        var that = this
        if(this.props.auth.displayName !== null){
            getFirestore().collection('users').doc(this.props.auth.displayName).get()
            .then(function(doc) {
                if (doc.exists) {
                    if(doc.data().photoURL !== undefined){
                        that.setState({
                            photoURL: doc.data().photoURL
                        })
                    }else{
                        that.setState({
                            photoURL: null
                        })
                    }
                } else {
                    message.error('Pic does not exist')
                }
            }).catch(function(error) {
                message.error(error)

redux-firestore

Redux bindings for Firestore.

MIT
Latest version published 12 months ago

Package Health Score

70 / 100
Full package analysis