openedx / frontend-app-discussions

A React-based micro frontend for the Open edX discussion forums.
GNU Affero General Public License v3.0
6 stars 61 forks source link

Decoding problem in posts preview body for non-lating alphabet languages #694

Open dagg opened 2 months ago

dagg commented 2 months ago

There is a problem in the left vertical list of the posts titles with the preview of the post body: The post body is not decoded correctly if it's written in a non-latin alphabet (For the Greek language in my case), as it is shown on my screenshot here.

Discussions_Decoding_Problem

The solution I have found and tested is quite simple though.

In the file frontend-app-discussions/src/discussions/posts/post/PostLink.jsx at the beginning you have to import 'he':

import he from 'he';

and at the following line: https://github.com/openedx/frontend-app-discussions/blob/2dafb6ad82f56e69ab19f9289d4a3d7958c29b89/src/discussions/posts/post/PostLink.jsx#L99

you have to decode the previewBody like so:

{isPostPreviewAvailable(previewBody) ? he.decode(previewBody) : intl.formatMessage(messages.postWithoutPreview)}

And that fixes the problem.

That's my solution but I guess there are other ways to deal with it as well...