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);
|
MmsSmsDatabase mmsSmsDatabase = DatabaseFactory.getMmsSmsDatabase(context);
|
||||||
long count = mmsSmsDatabase.getConversationCount(threadId);
|
long count = mmsSmsDatabase.getConversationCount(threadId);
|
||||||
|
|
||||||
|
boolean shouldDeleteEmptyThread = deleteThreadOnEmpty(threadId);
|
||||||
|
|
||||||
|
if (count == 0 && shouldDeleteEmptyThread) {
|
||||||
if (count == 0) {
|
|
||||||
deleteThread(threadId);
|
deleteThread(threadId);
|
||||||
notifyConversationListListeners();
|
notifyConversationListListeners();
|
||||||
return true;
|
return true;
|
||||||
@ -534,9 +534,12 @@ public class ThreadDatabase extends Database {
|
|||||||
notifyConversationListListeners();
|
notifyConversationListListeners();
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
deleteThread(threadId);
|
if (shouldDeleteEmptyThread) {
|
||||||
notifyConversationListListeners();
|
deleteThread(threadId);
|
||||||
return true;
|
notifyConversationListListeners();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (reader != null)
|
if (reader != null)
|
||||||
@ -544,6 +547,11 @@ public class ThreadDatabase extends Database {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean deleteThreadOnEmpty(long threadId) {
|
||||||
|
Recipient threadRecipient = getRecipientForThreadId(threadId);
|
||||||
|
return threadRecipient != null && !threadRecipient.isOpenGroupRecipient();
|
||||||
|
}
|
||||||
|
|
||||||
private @NonNull String getFormattedBodyFor(@NonNull MessageRecord messageRecord) {
|
private @NonNull String getFormattedBodyFor(@NonNull MessageRecord messageRecord) {
|
||||||
if (messageRecord.isMms()) {
|
if (messageRecord.isMms()) {
|
||||||
MmsMessageRecord record = (MmsMessageRecord) messageRecord;
|
MmsMessageRecord record = (MmsMessageRecord) messageRecord;
|
||||||
|
@ -70,10 +70,6 @@ public class GroupManager {
|
|||||||
final ThreadDatabase threadDatabase = DatabaseFactory.getThreadDatabase(context);
|
final ThreadDatabase threadDatabase = DatabaseFactory.getThreadDatabase(context);
|
||||||
final Recipient groupRecipient = Recipient.from(context, Address.fromSerialized(groupId), false);
|
final Recipient groupRecipient = Recipient.from(context, Address.fromSerialized(groupId), false);
|
||||||
|
|
||||||
if (!groupDatabase.getGroup(groupId).isPresent()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
long threadId = threadDatabase.getThreadIdIfExistsFor(groupRecipient);
|
long threadId = threadDatabase.getThreadIdIfExistsFor(groupRecipient);
|
||||||
if (threadId != -1L) {
|
if (threadId != -1L) {
|
||||||
threadDatabase.deleteConversation(threadId);
|
threadDatabase.deleteConversation(threadId);
|
||||||
|
Loading…
Reference in New Issue
Block a user