Skip to content

Commit

Permalink
Fix to parse OpenAI translations.
Browse files Browse the repository at this point in the history
The parsed result was without quotes which resulted in error:

Unterminated object at character 21 of [{fromLabel=English (US),

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
  • Loading branch information
mahibi committed Jun 30, 2023
1 parent 22f2dca commit cbf74cc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class TranslateActivity : BaseActivity() {

private fun getLanguageOptions() {
val currentUser = userManager.currentUser.blockingGet()
val json = JSONArray(CapabilitiesUtilNew.getLanguages(currentUser).toString())
val json = JSONArray((CapabilitiesUtilNew.getLanguages(currentUser) as ArrayList<*>).toArray())

val fromLanguagesSet = mutableSetOf(resources.getString(R.string.translation_detect_language))
val toLanguagesSet = mutableSetOf(resources.getString(R.string.translation_device_settings))
Expand Down Expand Up @@ -212,7 +212,7 @@ class TranslateActivity : BaseActivity() {

private fun getISOFromServer(language: String): String {
val currentUser = userManager.currentUser.blockingGet()
val json = JSONArray(CapabilitiesUtilNew.getLanguages(currentUser).toString())
val json = JSONArray((CapabilitiesUtilNew.getLanguages(currentUser) as ArrayList<*>).toArray())

for (i in 0 until json.length()) {
val current = json.getJSONObject(i)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class MessageActionsDialog(
!message.isDeleted &&
ChatMessage.MessageType.REGULAR_TEXT_MESSAGE == message.getCalculateMessageType() &&
CapabilitiesUtilNew.isTranslationsSupported(user) &&
JSONArray(CapabilitiesUtilNew.getLanguages(user).toString()).length() > 0
JSONArray((CapabilitiesUtilNew.getLanguages(user) as ArrayList<*>).toArray()).length() > 0
)
initMenuReplyToMessage(message.replyable && hasChatPermission)
initMenuReplyPrivately(
Expand Down

0 comments on commit cbf74cc

Please sign in to comment.