From b2cb04055d0bcbac7ffc0a36d2fe2b65f9f09087 Mon Sep 17 00:00:00 2001 From: Kyle Szklenski Date: Thu, 18 Jul 2024 12:32:20 -0400 Subject: [PATCH] Fix null/empty doc null ref --- addons/godot-firebase/firestore/firestore_document.gd | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/godot-firebase/firestore/firestore_document.gd b/addons/godot-firebase/firestore/firestore_document.gd index 256a75c..539db2a 100644 --- a/addons/godot-firebase/firestore/firestore_document.gd +++ b/addons/godot-firebase/firestore/firestore_document.gd @@ -19,10 +19,12 @@ var collection_name : String # Name of the collection to which it belongs signal changed(changes) func _init(doc : Dictionary = {}): - document = doc.fields - doc_name = doc.name - if doc_name.count("/") > 2: - doc_name = (doc_name.split("/") as Array).back() + if doc.has("fields"): + document = doc.fields + if doc.has("name"): + doc_name = doc.name + if doc_name.count("/") > 2: + doc_name = (doc_name.split("/") as Array).back() self.create_time = doc.createTime