Skip to content

Commit

Permalink
fixed winner response getting (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonKirill authored Mar 3, 2025
1 parent b223722 commit b3d5b06
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions chat_client/static/js/message_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,15 @@ async function addPromptMessage(cid, userID, messageText, promptId, promptState)
const tableBody = document.getElementById(`${promptId}_tbody`);
if (await getCurrentSkin(cid) === CONVERSATION_SKINS.PROMPTS){
try {
const userData = await getUserData(userID);
promptState = PROMPT_STATES[promptState].toLowerCase();
if (!getUserPromptTR(promptId, userID)) {
const userData = await getUserData(userID);
const newUserRow = await buildSubmindHTML(promptId, userID, userData, '', '', '');
tableBody.insertAdjacentHTML('beforeend', newUserRow);
}
try {
const messageElem = document.getElementById(`${promptId}_${userID}_${promptState}`);
console.log("userData:", userData)
const messageElem = document.getElementById(`${promptId}_${userData['nickname']}_${promptState}`);
messageElem.innerText = messageText;
} catch (e) {
console.warn(`Failed to add prompt message (${cid},${userID}, ${messageText}, ${promptId}, ${promptState}) - ${e}`)
Expand Down
3 changes: 2 additions & 1 deletion chat_client/static/js/sio.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ function initSIO(){
console.info(`setting prompt_id=${promptID} as completed`);
if (promptElem){
const promptWinner = document.getElementById(`${promptID}_winner`);
const winner_response = document.getElementById(`${promptID}_${data['winner']}_resp`).innerText;
console.log("data:", data)
promptWinner.innerHTML = await buildPromptWinnerHTML(data['winner']);
promptWinner.innerHTML = await buildPromptWinnerHTML(data['winner'], winner_response);
}else {
console.warn(`Failed to get HTML element from prompt_id=${promptID}`);
}
Expand Down
6 changes: 3 additions & 3 deletions chat_client/templates/components/prompt_participant.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
{participant_icon}
</td>
<td>
<div style="overflow-y:auto; width:100%; max-height: 150px!important;" id="{prompt_id}_{user_id}_resp"
<div style="overflow-y:auto; width:100%; max-height: 150px!important;" id="{prompt_id}_{user_nickname}_resp"
data-message-id="{response_message_id}"
data-created-on="{response_created_on}"
data-toggle="tooltip"
title="{response_created_on_tooltip}">{response}
</div>
</td>
<td id="{prompt_id}_{user_id}_disc"
<td id="{prompt_id}_{user_nickname}_disc"
data-created-on="{opinion_created_on}"
data-message-id="{opinion_message_id}"
data-toggle="tooltip"
title="{opinion_created_on_tooltip}">{opinion}
</td>
<td id="{prompt_id}_{user_id}_vote"
<td id="{prompt_id}_{user_nickname}_vote"
data-created-on="{vote_created_on}"
data-message-id="{vote_message_id}"
data-toggle="tooltip"
Expand Down
1 change: 0 additions & 1 deletion chat_server/sio/handlers/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ async def prompt_completed(sid, data):
prompt_id = data["context"]["prompt"]["prompt_id"]

LOG.info(f"setting {prompt_id = } as completed")

MongoDocumentsAPI.PROMPTS.set_completed(
prompt_id=prompt_id, prompt_context=data["context"]
)
Expand Down

0 comments on commit b3d5b06

Please sign in to comment.