feat(ui/chat_action_menu): show chat edit history
Signed-off-by: rhunk <101876869+rhunk@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
package me.rhunk.snapenhance.bridge.logger;
|
||||
|
||||
parcelable LoggedChatEdit {
|
||||
long timestamp;
|
||||
String message;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package me.rhunk.snapenhance.bridge.logger;
|
||||
|
||||
import me.rhunk.snapenhance.bridge.logger.BridgeLoggedMessage;
|
||||
import me.rhunk.snapenhance.bridge.logger.LoggedChatEdit;
|
||||
|
||||
interface LoggerInterface {
|
||||
/**
|
||||
@@ -38,4 +39,6 @@ interface LoggerInterface {
|
||||
String eventType,
|
||||
String data
|
||||
);
|
||||
|
||||
List<LoggedChatEdit> getChatEdits(String conversationId, long messageId);
|
||||
}
|
||||
@@ -1407,6 +1407,7 @@
|
||||
"preview_button": "Preview",
|
||||
"download_button": "Download",
|
||||
"delete_logged_message_button": "Delete Logged Message",
|
||||
"show_chat_edit_history": "Show Chat Edit History",
|
||||
"convert_message": "Convert Message",
|
||||
"edit_message": "Edit Message"
|
||||
},
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.google.gson.GsonBuilder
|
||||
import com.google.gson.JsonObject
|
||||
import kotlinx.coroutines.*
|
||||
import me.rhunk.snapenhance.bridge.logger.BridgeLoggedMessage
|
||||
import me.rhunk.snapenhance.bridge.logger.LoggedChatEdit
|
||||
import me.rhunk.snapenhance.bridge.logger.LoggerInterface
|
||||
import me.rhunk.snapenhance.common.bridge.InternalFileHandleType
|
||||
import me.rhunk.snapenhance.common.data.StoryData
|
||||
@@ -20,11 +21,6 @@ import me.rhunk.snapenhance.common.util.protobuf.ProtoReader
|
||||
import java.io.File
|
||||
import java.util.UUID
|
||||
|
||||
class LoggedMessageEdit(
|
||||
val timestamp: Long,
|
||||
val messageText: String
|
||||
)
|
||||
|
||||
class LoggedMessage(
|
||||
val messageId: Long,
|
||||
val conversationId: String,
|
||||
@@ -422,17 +418,17 @@ class LoggerWrapper(
|
||||
return ConversationInfo(conversationId, participantSize, groupTitle, usernames)
|
||||
}
|
||||
|
||||
fun getMessageEdits(conversationId: String, messageId: Long): List<LoggedMessageEdit> {
|
||||
val edits = mutableListOf<LoggedMessageEdit>()
|
||||
override fun getChatEdits(conversationId: String, messageId: Long): List<LoggedChatEdit> {
|
||||
val edits = mutableListOf<LoggedChatEdit>()
|
||||
database.rawQuery(
|
||||
"SELECT added_timestamp, message_text FROM chat_edits WHERE conversation_id = ? AND message_id = ?",
|
||||
"SELECT added_timestamp, message_text FROM chat_edits WHERE conversation_id = ? AND message_id = ? ORDER BY added_timestamp ASC",
|
||||
arrayOf(conversationId, messageId.toString())
|
||||
).use {
|
||||
while (it.moveToNext()) {
|
||||
edits.add(LoggedMessageEdit(
|
||||
timestamp = it.getLongOrNull("added_timestamp") ?: continue,
|
||||
messageText = it.getStringOrNull("message_text") ?: continue
|
||||
))
|
||||
).use { cursor ->
|
||||
while (cursor.moveToNext()) {
|
||||
edits.add(LoggedChatEdit().apply {
|
||||
timestamp = cursor.getLongOrNull("added_timestamp") ?: return@apply
|
||||
message = cursor.getStringOrNull("message_text")
|
||||
}.takeIf { it.timestamp > 0L } ?: continue)
|
||||
}
|
||||
}
|
||||
return edits
|
||||
|
||||
Reference in New Issue
Block a user