Fixes a bug where transformed messages would appear differently after page refresh. A user's transformed message stays shown with the original message in bold, and the info message "xml tagging enabled, your message has been transformed" remains.
Screenshots
Notes
main ticket changes
We have the type transformedMessage which keeps a pre-message, message and post-message string, allowing us to render those parts of the string differently in the chat feed. The backend chat history now stores an optional transformedMessage of this type, which is returned to the frontend for rendering. This fixes the transformed message appearing differently after refresh.
To fix the info message disappearing, we now add the info message to the backend's chat history as part of the logic which does the transformation to the user's message in the backend. To get the info message to the frontend for rendering in the chat box feed, we return it as a new property in ChatHttpResponse
testing
New unit test added to chatController.test which checks that the history is updated properly with the transformed message and info message.
Refactors the unit tests for transforming messages and moves them into their own file.
refactoring
combines two if statemets in processChatResponse which were both checking if we had met the win condition.
renames incrementNumCompletedLevels to updateNumCompletedLevels (this is called when we win a level. Renamed it because we don't increment if the beaten level has been beaten before.)
renames ChatHistoryMessage to ChatMessageDTO (this is the object that is returned when the frontend requests the entire chat history)
refactors getChatHistory method in frontend's chatService.ts just to make it read a bit more clearly.
transformedMessage, transformedMessageInfo and transformedMessageCombined are now packaged under one object: messageTransformation. It is an object of this type, which is now returned by transformMessage
We remove the isTriggered property from Defence because it wasn't being used anymore (replaced by defenceReport)
Concerns
Happy to move some refactorings to a separate PR if requested.
Description
Fixes a bug where transformed messages would appear differently after page refresh. A user's transformed message stays shown with the original message in bold, and the info message "xml tagging enabled, your message has been transformed" remains.
Screenshots
Notes
main ticket changes
transformedMessage
which keeps a pre-message, message and post-message string, allowing us to render those parts of the string differently in the chat feed. The backend chat history now stores an optionaltransformedMessage
of this type, which is returned to the frontend for rendering. This fixes the transformed message appearing differently after refresh.ChatHttpResponse
testing
refactoring
processChatResponse
which were both checking if we had met the win condition.incrementNumCompletedLevels
toupdateNumCompletedLevels
(this is called when we win a level. Renamed it because we don't increment if the beaten level has been beaten before.)ChatHistoryMessage
toChatMessageDTO
(this is the object that is returned when the frontend requests the entire chat history)getChatHistory
method in frontend's chatService.ts just to make it read a bit more clearly.transformedMessage
,transformedMessageInfo
andtransformedMessageCombined
are now packaged under one object:messageTransformation
. It is an object of this type, which is now returned bytransformMessage
isTriggered
property fromDefence
because it wasn't being used anymore (replaced by defenceReport)Concerns
Checklist
Have you done the following?