* Triggers every time there is a change in the Firebase auth state (i.e. user signed-in or user signed out).
(user: User | null)
| 541 | * Triggers every time there is a change in the Firebase auth state (i.e. user signed-in or user signed out). |
| 542 | */ |
| 543 | function onAuthChanged(user: User | null) { |
| 544 | // We ignore token refresh events. |
| 545 | if (user && currentUID === user.uid) { |
| 546 | return; |
| 547 | } |
| 548 | |
| 549 | cleanupUi(); |
| 550 | if (user) { |
| 551 | currentUID = user.uid; |
| 552 | splashPage.style.display = 'none'; |
| 553 | writeUserData(user.uid, user.displayName, user.email, user.photoURL); |
| 554 | startDatabaseQueries(); |
| 555 | } else { |
| 556 | // Set currentUID to null. |
| 557 | currentUID = null; |
| 558 | // Display the splash page where you can sign-in. |
| 559 | splashPage.style.display = ''; |
| 560 | } |
| 561 | } |
| 562 | |
| 563 | /** |
| 564 | * Creates a new post for the current user. |
nothing calls this directly
no test coverage detected