mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-11 17:33:39 +00:00
Merge pull request #549 from hjubb/fix_deleting_necessary_empty_threads
Don't Auto-Delete Empty Open Groups
This commit is contained in:
commit
8e9deba756
@ -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…
x
Reference in New Issue
Block a user