Initial fix implemented

This commit is contained in:
Al Lansley 2024-04-08 13:53:18 +10:00
parent 34eedc0fdb
commit ad51746e84
4 changed files with 12 additions and 9 deletions

View File

@ -1112,6 +1112,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
val blindedRecipient = viewModel.blindedRecipient val blindedRecipient = viewModel.blindedRecipient
val binding = binding ?: return val binding = binding ?: return
val openGroup = viewModel.openGroup val openGroup = viewModel.openGroup
val (textResource, insertParam) = when { val (textResource, insertParam) = when {
recipient.isLocalNumber -> R.string.activity_conversation_empty_state_note_to_self to null recipient.isLocalNumber -> R.string.activity_conversation_empty_state_note_to_self to null
openGroup != null && !openGroup.canWrite -> R.string.activity_conversation_empty_state_read_only to recipient.toShortString() openGroup != null && !openGroup.canWrite -> R.string.activity_conversation_empty_state_read_only to recipient.toShortString()
@ -1883,11 +1884,13 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
return return
} }
val allSentByCurrentUser = messages.all { it.isOutgoing } val allSentByCurrentUser = messages.all { it.isOutgoing }
val allHasHash = messages.all { lokiMessageDb.getMessageServerHash(it.id, it.isMms) != null } val allHasHash = messages.all { lokiMessageDb.getMessageServerHash(it.id, it.isMms) != null }
// If the recipient is a community then we delete the message for everyone // If the recipient is a community OR a Note-to-Self then we delete the message for everyone
if (recipient.isCommunityRecipient) { if (recipient.isCommunityRecipient || recipient.isLocalNumber) {
val messageCount = 1 // Only used for plurals string val messageCount = 1 // Only used for plurals string
showSessionDialog { showSessionDialog {
title(resources.getQuantityString(R.plurals.ConversationFragment_delete_selected_messages, messageCount, messageCount)) title(resources.getQuantityString(R.plurals.ConversationFragment_delete_selected_messages, messageCount, messageCount))
@ -1917,8 +1920,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
} }
bottomSheet.show(supportFragmentManager, bottomSheet.tag) bottomSheet.show(supportFragmentManager, bottomSheet.tag)
} }
else // Finally, if this is a closed group and you are deleting someone else's message(s) else // Finally, if this is a closed group and you are deleting someone else's message(s) then we can only delete locally.
// then we can only delete locally.
{ {
val messageCount = 1 val messageCount = 1
showSessionDialog { showSessionDialog {
@ -2027,7 +2029,6 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
val message = messages.first() as MmsMessageRecord val message = messages.first() as MmsMessageRecord
// Do not allow the user to download a file attachment before it has finished downloading // Do not allow the user to download a file attachment before it has finished downloading
// TODO: Localise the msg in this toast!
if (message.isMediaPending) { if (message.isMediaPending) {
Toast.makeText(this, resources.getString(R.string.conversation_activity__wait_until_attachment_has_finished_downloading), Toast.LENGTH_LONG).show() Toast.makeText(this, resources.getString(R.string.conversation_activity__wait_until_attachment_has_finished_downloading), Toast.LENGTH_LONG).show()
return return

View File

@ -1095,8 +1095,7 @@ class MmsDatabase(context: Context, databaseHelper: SQLCipherOpenHelper) : Messa
} }
val whereString = where.substring(0, where.length - 4) val whereString = where.substring(0, where.length - 4)
try { try {
cursor = cursor = db!!.query(TABLE_NAME, arrayOf<String?>(ID), whereString, null, null, null, null)
db!!.query(TABLE_NAME, arrayOf<String?>(ID), whereString, null, null, null, null)
val toDeleteStringMessageIds = mutableListOf<String>() val toDeleteStringMessageIds = mutableListOf<String>()
while (cursor.moveToNext()) { while (cursor.moveToNext()) {
toDeleteStringMessageIds += cursor.getLong(0).toString() toDeleteStringMessageIds += cursor.getLong(0).toString()

View File

@ -633,6 +633,7 @@ public class SmsDatabase extends MessagingDatabase {
SQLiteDatabase db = databaseHelper.getWritableDatabase(); SQLiteDatabase db = databaseHelper.getWritableDatabase();
long threadId = getThreadIdForMessage(messageId); long threadId = getThreadIdForMessage(messageId);
db.delete(TABLE_NAME, ID_WHERE, new String[] {messageId+""}); db.delete(TABLE_NAME, ID_WHERE, new String[] {messageId+""});
notifyConversationListeners(threadId);
boolean threadDeleted = DatabaseComponent.get(context).threadDatabase().update(threadId, false, true); boolean threadDeleted = DatabaseComponent.get(context).threadDatabase().update(threadId, false, true);
return threadDeleted; return threadDeleted;
} }

View File

@ -515,11 +515,13 @@ public class ThreadDatabase extends Database {
return getConversationList(where); return getConversationList(where);
} }
/*
public Cursor getArchivedConversationList() { public Cursor getArchivedConversationList() {
String where = "(" + MESSAGE_COUNT + " != 0 OR " + GroupDatabase.TABLE_NAME + "." + GROUP_ID + " LIKE '" + COMMUNITY_PREFIX + "%') " + String where = "(" + MESSAGE_COUNT + " != 0 OR " + GroupDatabase.TABLE_NAME + "." + GROUP_ID + " LIKE '" + COMMUNITY_PREFIX + "%') " +
"AND " + ARCHIVED + " = 1 "; "AND " + ARCHIVED + " = 1 ";
return getConversationList(where); return getConversationList(where);
} }
*/
private Cursor getConversationList(String where) { private Cursor getConversationList(String where) {
SQLiteDatabase db = databaseHelper.getReadableDatabase(); SQLiteDatabase db = databaseHelper.getReadableDatabase();
@ -771,11 +773,11 @@ public class ThreadDatabase extends Database {
deleteThread(threadId); deleteThread(threadId);
return true; return true;
} }
// todo: add empty snippet that clears existing data
return false; return false;
} }
} finally { } finally {
if (reader != null) if (reader != null) { reader.close(); }
reader.close();
notifyConversationListListeners(); notifyConversationListListeners();
notifyConversationListeners(threadId); notifyConversationListeners(threadId);
} }