Fix miscalculation of groups in common.

This commit is contained in:
Alex Hart
2023-02-15 14:11:24 -04:00
committed by Greyson Parrelli
parent 6759b59507
commit e2c3db3eda
7 changed files with 141 additions and 9 deletions

View File

@@ -1,6 +1,7 @@
package org.thoughtcrime.securesms.contacts.paged
import android.content.Context
import org.signal.core.util.logging.Log
import org.thoughtcrime.securesms.R
/**
@@ -12,6 +13,10 @@ data class GroupsInCommon(
) {
fun toDisplayText(context: Context): String {
return when (total) {
0 -> {
Log.w(TAG, "Member with no groups in common!")
return ""
}
1 -> context.getString(R.string.MessageRequestProfileView_member_of_one_group, names[0])
2 -> context.getString(R.string.MessageRequestProfileView_member_of_two_groups, names[0], names[1])
else -> context.getString(
@@ -22,4 +27,8 @@ data class GroupsInCommon(
)
}
}
companion object {
private val TAG = Log.tag(GroupsInCommon::class.java)
}
}

View File

@@ -565,7 +565,7 @@ class GroupTable(context: Context?, databaseHelper: SignalDatabase?) : DatabaseT
) as $MEMBER_GROUP_CONCAT
FROM ${MembershipTable.TABLE_NAME}
INNER JOIN $TABLE_NAME ON ${MembershipTable.TABLE_NAME}.${MembershipTable.GROUP_ID} = $TABLE_NAME.$GROUP_ID
INNER JOIN ${ThreadTable.TABLE_NAME} ON $TABLE_NAME.$RECIPIENT_ID = ${ThreadTable.TABLE_NAME}.${ThreadTable.RECIPIENT_ID}
LEFT JOIN ${ThreadTable.TABLE_NAME} ON $TABLE_NAME.$RECIPIENT_ID = ${ThreadTable.TABLE_NAME}.${ThreadTable.RECIPIENT_ID}
""".toSingleLine()
var query = "${MembershipTable.TABLE_NAME}.${MembershipTable.RECIPIENT_ID} = ?"

View File

@@ -1533,7 +1533,8 @@ public class MessageTable extends DatabaseTable implements MessageTypes, Recipie
return releaseChannelThreadId;
}
private void deleteGroupStoryReplies(long parentStoryId) {
@VisibleForTesting
public void deleteGroupStoryReplies(long parentStoryId) {
SQLiteDatabase db = databaseHelper.getSignalWritableDatabase();
String[] args = SqlUtil.buildArgs(parentStoryId);