Skip to content

Commit

Permalink
WIP offline reactions - got it working - However removing it does not…
Browse files Browse the repository at this point in the history
… update instantly, need to fix that. Next will be offline reaction inspecting -> offline delete messages -> offline system messages

Signed-off-by: rapterjet2004 <[email protected]>
  • Loading branch information
rapterjet2004 committed Jul 19, 2024
1 parent 3c848f5 commit d7d5ebe
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

package com.nextcloud.talk.data.source.local.converters

import android.util.Log
import androidx.room.TypeConverter
import com.bluelinelabs.logansquare.LoganSquare

Expand All @@ -17,7 +18,12 @@ class ArrayListConverter {
return if (list == null) {
null
} else {
return LoganSquare.serialize(list)
return try {
LoganSquare.serialize(list)
} catch (e: Exception) {
Log.e("ArrayListConverter", "Error parsing array list $list to String $e")
""
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

package com.nextcloud.talk.data.source.local.converters

import android.util.Log
import androidx.room.TypeConverter
import com.fasterxml.jackson.core.JsonFactory
import java.io.IOException
Expand All @@ -18,15 +19,26 @@ class LinkedHashMapConverter {

@TypeConverter
fun stringToLinkedHashMap(value: String?): LinkedHashMap<String, Int> {
if (value.isNullOrEmpty()) {
if (value.isNullOrEmpty() || value == "{}") {
return linkedMapOf()
}
// "{"πŸ‘":1,"πŸ‘Ž":1,"πŸ˜ƒ":1,"😯":1}" // pretend this is value
return try {
jsonFactory.createParser(value).use { parser ->
converter.parse(parser)
val map = linkedMapOf<String, Int>()
val trimmed = value.replace("{", "").replace("}", "")
// "πŸ‘":1,"πŸ‘Ž":1,"πŸ˜ƒ":1,"😯":1
val mapList = trimmed.split(",")
// ["πŸ‘":1]["πŸ‘Ž":1]["πŸ˜ƒ":1]["😯":1]
for (mapStr in mapList) {
val emojiMapList = mapStr.split(":")
val emoji = emojiMapList[0].replace("\"", "") // removes double quotes
val count = emojiMapList[1].toInt()
map[emoji] = count
}
// [πŸ‘:1],[πŸ‘Ž:1],[πŸ˜ƒ:1],[😯:1]
return map
} catch (e: IOException) {
// e.printStackTrace()
Log.e("LinkedHashMapConverter", "Error parsing string: $value to linkedHashMap $e")
linkedMapOf()
}
}
Expand Down

0 comments on commit d7d5ebe

Please sign in to comment.