From e8ad6e5124a7fe1cb68574b02c3c1f9f20e2bb8e Mon Sep 17 00:00:00 2001 From: Gordon MacPherson Date: Tue, 26 Mar 2024 16:54:11 +0000 Subject: [PATCH] Fix viewing space causing assertion Why: - _space.creator can be a dictionary or a string id. We must deal with both cases for now. --- .../ui/main_menu/pages/view_space.gd | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/mirror-godot-app/ui/main_menu/pages/view_space.gd b/mirror-godot-app/ui/main_menu/pages/view_space.gd index 7a9e2582..2a1efa06 100644 --- a/mirror-godot-app/ui/main_menu/pages/view_space.gd +++ b/mirror-godot-app/ui/main_menu/pages/view_space.gd @@ -120,14 +120,19 @@ func populate(space: Dictionary) -> void: var updated = Time.get_datetime_dict_from_datetime_string(_space.get('updatedAt', ""), false) _updated_at_label.text = Util.datetime_dict_to_mmm_dd_yyyy(updated) _url_label.text = _construct_space_url(_space.get("_id", "unknown")) - var creator_promise: Promise = Net.user_client.get_user_profile(_space.creator) - creator_promise.connect_func_to_fulfill(func(): - if creator_promise.is_error(): - push_error("Failed to get creator") - var data = creator_promise.get_result() - var creator_name = data.get("displayName", tr("Unknown")) + + if _space.creator is String: + var creator_promise: Promise = Net.user_client.get_user_profile(_space.creator) + creator_promise.connect_func_to_fulfill(func(): + if creator_promise.is_error(): + push_error("Failed to get creator") + var data = creator_promise.get_result() + var creator_name = data.get("displayName", tr("Unknown")) + _creator_label.text = tr("Created by {0}").format([creator_name]) + ) + else: + var creator_name = _space.creator.get("displayName", tr("Unknown")) _creator_label.text = tr("Created by {0}").format([creator_name]) - ) _description_label.text = _preprocess_description(_space.get("description","")) if _description_label.text == "": _description_label.text = tr("No description was provided for this space.")