From 7ab0ae9ac8151f6785e64bfd1da8933523721d17 Mon Sep 17 00:00:00 2001 From: Fangh Date: Sun, 28 Jan 2024 16:23:53 +0100 Subject: [PATCH] fix: if user has given no proposition --- Assets/Scripts/PropositionFrame.cs | 4 +++- Assets/Scripts/VotingPage.cs | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/PropositionFrame.cs b/Assets/Scripts/PropositionFrame.cs index f0d76a4..c5313b9 100644 --- a/Assets/Scripts/PropositionFrame.cs +++ b/Assets/Scripts/PropositionFrame.cs @@ -22,8 +22,10 @@ public void Initialize(Proposition _proposition) { Debug.Log($"Initializing {_proposition.owner}'s proposition", this); proposition = _proposition; - DisplayPicture(proposition.photoUrl); playerName.text = proposition.owner.name; + + if (!string.IsNullOrEmpty(proposition.photoUrl)) + DisplayPicture(proposition.photoUrl); } private void DisplayPicture(string _url) diff --git a/Assets/Scripts/VotingPage.cs b/Assets/Scripts/VotingPage.cs index 04043ee..78b762d 100644 --- a/Assets/Scripts/VotingPage.cs +++ b/Assets/Scripts/VotingPage.cs @@ -88,8 +88,22 @@ void ShowQuestion() Debug.Log($"Prompt is {currentPromptLabel.text}", this); - proposition1.Initialize(currentQuestion.propositions[0]); - proposition1.Initialize(currentQuestion.propositions[1]); + if (currentQuestion.propositions[0] != null) + proposition1.Initialize(currentQuestion.propositions[0]); + else + { + Debug.Log("User has given no proposition", this); + //manage if there is no proposition + } + + if (currentQuestion.propositions[1] != null) + proposition2.Initialize(currentQuestion.propositions[1]); + else + { + Debug.Log("User has given no proposition", this); + //manage if there is no proposition + } + endOfTimer = DateTime.Now.AddSeconds(votingTime); }