8000 Issue #24 set author to 'Anonymous' instead of 'undefined' when there… · cloudwizard/quickstart-js@1bec446 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1bec446

Browse files
committed
Issue firebase#24 set author to 'Anonymous' instead of 'undefined' when there is no G+ profile enabled on the google account
1 parent d232ae2 commit 1bec446

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

database/scripts/main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function createPostElement(postId, title, text, author, authorId, authorPic) {
129129
// Set values.
130130
postElement.getElementsByClassName('text')[0].innerText = text;
131131
postElement.getElementsByClassName('mdl-card__title-text')[0].innerText = title;
132-
postElement.getElementsByClassName('username')[0].innerText = author;
132+
postElement.getElementsByClassName('username')[0].innerText = author || 'Anonymous';
133133
postElement.getElementsByClassName('avatar')[0].style.backgroundImage = `url("${authorPic || './silhouette.jpg'}")`;
134134

135135
// Listen for comments.
@@ -258,9 +258,10 @@ function startDatabaseQueries() {
258258

259259
var fetchPosts = function(postsRef, sectionElement) {
260260
postsRef.on('child_added', function(data) {
261+
var author = data.val().author || 'Anonymous';
261262
var containerElement = sectionElement.getElementsByClassName('posts-container')[0];
262263
containerElement.insertBefore(
263-
createPostElement(data.key, data.val().title, data.val().body, data.val().author, data.val().uid),
264+
createPostElement(data.key, data.val().title, data.val().body, author, data.val().uid),
264265
containerElement.firstChild);
265266
});
266267
};

0 commit comments

Comments
 (0)
0