mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
refactor: don't delete empty threads if they're open groups
This commit is contained in:
parent
6ac534482f
commit
1cc0b0ee7d
@ -513,9 +513,9 @@ public class ThreadDatabase extends Database {
|
||||
MmsSmsDatabase mmsSmsDatabase = DatabaseFactory.getMmsSmsDatabase(context);
|
||||
long count = mmsSmsDatabase.getConversationCount(threadId);
|
||||
|
||||
boolean shouldDeleteEmptyThread = deleteThreadOnEmpty(threadId);
|
||||
|
||||
|
||||
if (count == 0) {
|
||||
if (count == 0 && shouldDeleteEmptyThread) {
|
||||
deleteThread(threadId);
|
||||
notifyConversationListListeners();
|
||||
return true;
|
||||
@ -534,16 +534,24 @@ public class ThreadDatabase extends Database {
|
||||
notifyConversationListListeners();
|
||||
return false;
|
||||
} else {
|
||||
if (shouldDeleteEmptyThread) {
|
||||
deleteThread(threadId);
|
||||
notifyConversationListListeners();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} finally {
|
||||
if (reader != null)
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean deleteThreadOnEmpty(long threadId) {
|
||||
Recipient threadRecipient = getRecipientForThreadId(threadId);
|
||||
return threadRecipient != null && !threadRecipient.isOpenGroupRecipient();
|
||||
}
|
||||
|
||||
private @NonNull String getFormattedBodyFor(@NonNull MessageRecord messageRecord) {
|
||||
if (messageRecord.isMms()) {
|
||||
MmsMessageRecord record = (MmsMessageRecord) messageRecord;
|
||||
|
@ -70,10 +70,6 @@ public class GroupManager {
|
||||
final ThreadDatabase threadDatabase = DatabaseFactory.getThreadDatabase(context);
|
||||
final Recipient groupRecipient = Recipient.from(context, Address.fromSerialized(groupId), false);
|
||||
|
||||
if (!groupDatabase.getGroup(groupId).isPresent()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
long threadId = threadDatabase.getThreadIdIfExistsFor(groupRecipient);
|
||||
if (threadId != -1L) {
|
||||
threadDatabase.deleteConversation(threadId);
|
||||
|
Loading…
Reference in New Issue
Block a user