gifFirebaseRef.on('value', snapshot => { const gifURL = snapshot.val() || ''; // got the url, stop listening for changes if (gifURL) { gifFirebaseRef.off(); this.goOffline(); setMessage(''); this.setState( { gifFirebaseRef, gifURL, loading: false, processing: false }, () => { this.updateBackgroundColor(); this.updateAddThis(); }, ); } else if (!processing) { this.goOffline(); setMessage(''); // user opened by url // we saw if exists. it didnt. so lets redirect it to the main page push(`/#${subject}`); } });
const saveUser = user => { return firebase.database().ref(`/users/${user.uid}`).update({ displayName: user.displayName || '', photoURL: user.photoURL || '', uid: user.uid, }); }
const fetchPlaces = (regionId) => { return database.ref(apiUris.places) .orderByChild('regionId') .equalTo(parseInt(regionId)) .once('value') .then((snapshot) => { return snapshot.val() || []; }) }
const startEditExpense = (id, updates) => { return (dispatch, getState) => { const uid = getState().auth.uid; return database.ref(`users/${uid}/expenses/${id}`).update(updates) .then(() => { dispatch(editExpense(id,updates)); }); }; }
handleAddRoom(newRoom) { this.roomRef.push({ name: newRoom, owner: this.props.user.displayName, ownerId: this.props.user.uid, creationDate: Date.now(), }).then(data => { this.showAlert() }) }
export function addComment(param) { return function (dispatch) { let path = "/Comments/" + param.title; firebase.database().ref(path).push(param.comment) } }
const deleteWish = (wishId, userId) => { let updates = {}; updates[`/wishes/${wishId}`] = null; updates[`/users/${userId}/wishes/${wishId}`] = null; return firebase.database().ref().update(updates); }
gifFirebaseRef.on('value', snapshot => { const gifURL = snapshot.val() || ''; // got the url, stop listening for changes if (gifURL) { gifFirebaseRef.off(); this.goOffline(); setMessage(''); this.setState( { gifFirebaseRef, gifURL, loading: false, processing: false }, () => { this.updateBackgroundColor(); this.updateAddThis(); }, ); } else if (!processing) { this.goOffline(); setMessage(''); // user opened by url // we saw if exists. it didnt. so lets redirect it to the main page push(`/#${subject}`); } });
const upwish = (wishId, authorUid, uid) => { let updates = {}; updates[`/wishes/${wishId}/upwishes/${uid}`] = true; updates[`/users/${authorUid}/wishes/${wishId}/upwishes/${uid}`] = true; return firebase.database().ref().update(updates); }