Skip to content

SES-3437 : Community Mentions Inconsistent #1362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import org.thoughtcrime.securesms.database.DatabaseContentProviders.Conversation
import org.thoughtcrime.securesms.database.GroupDatabase
import org.thoughtcrime.securesms.database.GroupMemberDatabase
import org.thoughtcrime.securesms.database.MmsDatabase
import org.thoughtcrime.securesms.database.MmsSmsDatabase
import org.thoughtcrime.securesms.database.SessionContactDatabase
import org.thoughtcrime.securesms.database.Storage
import org.thoughtcrime.securesms.database.ThreadDatabase
Expand All @@ -69,6 +70,7 @@ class MentionViewModel(
storage: Storage,
configFactory: ConfigFactoryProtocol,
dispatcher: CoroutineDispatcher = Dispatchers.IO,
mmsSmsDatabase: MmsSmsDatabase
) : ViewModel() {
private val editable = MentionEditable()

Expand Down Expand Up @@ -108,7 +110,7 @@ class MentionViewModel(
)
.map { it.toString() }
}
recipient.isCommunityRecipient -> mmsDatabase.getRecentChatMemberIDs(
recipient.isCommunityRecipient -> mmsSmsDatabase.getRecentChatMemberAddresses(
threadID,
20
)
Expand Down Expand Up @@ -374,6 +376,7 @@ class MentionViewModel(
private val memberDatabase: GroupMemberDatabase,
private val configFactory: ConfigFactoryProtocol,
private val application: Application,
private val mmsSmsDatabase : MmsSmsDatabase
) : ViewModelProvider.Factory {
@Suppress("UNCHECKED_CAST")
override fun <T : ViewModel> create(modelClass: Class<T>): T {
Expand All @@ -388,6 +391,7 @@ class MentionViewModel(
storage = storage,
configFactory = configFactory,
application = application,
mmsSmsDatabase = mmsSmsDatabase
) as T
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,24 @@ public Cursor getConversationSnippet(long threadId) {
return queryTables(PROJECTION, selection, order, null);
}

public List<String> getRecentChatMemberAddresses(long threadId, int limit) {
String[] projection = new String[] { "DISTINCT " + MmsSmsColumns.ADDRESS };
String selection = MmsSmsColumns.THREAD_ID + " = " + threadId;
String order = MmsSmsColumns.NORMALIZED_DATE_SENT + " DESC";
String limitStr = String.valueOf(limit);

try (Cursor cursor = queryTables(projection, selection, order, limitStr)) {
List<String> addresses = new ArrayList<>();
while (cursor != null && cursor.moveToNext()) {
String address = cursor.getString(0);
if (address != null && !address.isEmpty()) {
addresses.add(address);
}
}
return addresses;
}
}

public List<MessageRecord> getUserMessages(long threadId, String sender) {

List<MessageRecord> idList = new ArrayList<>();
Expand Down
Loading