Skip to content

Commit 7f273ec

Browse files
committed
Fix notes
1 parent b1ae960 commit 7f273ec

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

src/components/Firebase/firebase.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,8 @@ class Firebase {
2424
/* Firebase APIs */
2525

2626
this.auth = app.auth();
27-
28-
/* FireStore */
2927
this.db = app.firestore();
30-
const settings = { timestampsInSnapshots: true};
31-
this.db.settings(settings);
28+
this.db.settings({ timestampsInSnapshots: true});
3229

3330
/* Social Sign In Method Provider */
3431

src/components/Home/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ class HomePage extends Component {
2323
snapshot.forEach(doc => (users[doc.id] = doc.data()));
2424

2525
this.setState({
26-
users: users,
26+
users,
2727
});
2828
});
2929
}
3030

3131
componentWillUnmount() {
32-
this.unsubscribe && this.unsubscribe();
32+
this.unsubscribe();
3333
}
3434

3535
render() {

src/components/Messages/Messages.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,24 @@ class Messages extends Component {
2929
.orderBy('createdAt', 'desc')
3030
.limit(this.state.limit) // firestore doesn't have limitLast, so we use combination of order desc and limit
3131
.onSnapshot(snapshot => {
32-
let messageList = [];
32+
let messages;
3333

34-
snapshot.forEach(doc =>
35-
messageList.push({ ...doc.data(), uid: doc.id }),
36-
);
34+
if (snapshot.size) {
35+
messages = [];
36+
snapshot.forEach(doc =>
37+
messages.push({ ...doc.data(), uid: doc.id }),
38+
);
39+
}
3740

3841
this.setState({
39-
messages: messageList.reverse(),
42+
messages,
4043
loading: false,
4144
});
4245
});
4346
};
4447

4548
componentWillUnmount() {
46-
this.unsubscribe && this.unsubscribe();
49+
this.unsubscribe();
4750
}
4851

4952
onChangeText = event => {

src/components/Users/UserItem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class UserItem extends Component {
3232
}
3333

3434
componentWillUnmount() {
35-
this.unsubscribe && this.unsubscribe();
35+
this.unsubscribe();
3636
}
3737

3838
onSendPasswordResetEmail = () => {

src/components/Users/UserList.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,21 @@ class UserList extends Component {
2121
this.unsubscribe = this.props.firebase
2222
.users()
2323
.onSnapshot(snapshot => {
24-
let usersList = [];
24+
let users = [];
2525

2626
snapshot.forEach(doc =>
27-
usersList.push({ ...doc.data(), uid: doc.id }),
27+
users.push({ ...doc.data(), uid: doc.id }),
2828
);
2929

3030
this.setState({
31-
users: usersList,
31+
users,
3232
loading: false,
3333
});
3434
});
3535
}
3636

3737
componentWillUnmount() {
38-
this.unsubscribe && this.unsubscribe();
38+
this.unsubscribe();
3939
}
4040

4141
render() {

0 commit comments

Comments
 (0)