Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Fix: Setting stats "undefined" on new char sheet
Browse files Browse the repository at this point in the history
  • Loading branch information
rg-wood committed Oct 28, 2021
1 parent 2ed8518 commit 8a34254
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions lib/sync-value-behaviour.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@ export const SyncValueBehaviour = Base => class extends Base {
}

onAuthStateChanged(this.auth, async user => {
this.value = (await getDoc(doc(this.db, "stats", this.documentId))).get(this.id)

onSnapshot(doc(this.db, "stats", this.documentId), (doc) => {
this.value = doc.get(this.id)
const remoteValue = doc.get(this.id)
if (remoteValue) this.value = remoteValue
})
})
}
}

async syncValue(event) {
async syncValue() {
if(this.editable) {
const ref = await doc(collection(this.db, "stats"), this.documentId)

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "three-meet-char-sheet",
"version": "0.2.1",
"version": "0.2.2",
"description": "Character sheets for Three Meet ",
"keywords": [
"lit",
Expand Down

0 comments on commit 8a34254

Please sign in to comment.