Skip to content

Commit

Permalink
Re-add fields2dict
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangSenff committed Jun 10, 2024
1 parent 40e7b5c commit 24a576f
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions addons/godot-firebase/Utilities.gd
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,13 @@ static func from_firebase_type(value : Variant) -> Variant:
return null

if value.has("mapValue"):
value = _from_firebase_type_recursive(value.values()[0].fields)
value = fields2dict(value.values()[0])
elif value.has("timestampValue"):
value = Time.get_datetime_dict_from_datetime_string(value.values()[0], false)
else:
value = value.values()[0]

return value

static func _from_firebase_type_recursive(value : Variant) -> Variant:
if value == null:
return null

if value.has("mapValue") or value.has("timestampValue"):
value = _from_firebase_type_recursive(value.value()[0].fields)
else:
value = value.values()[0]

return value

static func to_firebase_type(value : Variant) -> Dictionary:
var var_type : String = ""
Expand Down Expand Up @@ -103,7 +92,7 @@ static func fields2dict(doc) -> Dictionary:
var dict = {}
if doc.has("fields"):
var fields = doc["fields"]
print(fields)

for field in fields.keys():
if fields[field].has("mapValue"):
dict[field] = (fields2dict(fields[field].mapValue))
Expand Down

0 comments on commit 24a576f

Please sign in to comment.