mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-03 12:32:17 +00:00
Clean GroupManager
This commit is contained in:
@@ -49,7 +49,7 @@ class MultiDeviceOpenGroupUpdateJob private constructor(parameters: Parameters)
|
||||
val record = reader.next ?: return@use
|
||||
if (!record.isPublicChat) { continue; }
|
||||
|
||||
val threadID = GroupManager.getThreadIdFromGroupId(record.encodedId, context)
|
||||
val threadID = GroupManager.getThreadIDFromGroupID(record.encodedId, context)
|
||||
val openGroup = DatabaseFactory.getLokiThreadDatabase(context).getPublicChat(threadID)
|
||||
if (openGroup != null) {
|
||||
openGroups.add(openGroup)
|
||||
|
||||
@@ -48,10 +48,10 @@ class LokiPublicChatManager(private val context: Context) {
|
||||
|
||||
public fun addChat(server: String, channel: Long, name: String): LokiPublicChat {
|
||||
val chat = LokiPublicChat(channel, server, name, true)
|
||||
var threadID = GroupManager.getPublicChatThreadId(chat.id, context)
|
||||
var threadID = GroupManager.getOpenGroupThreadID(chat.id, context)
|
||||
// Create the group if we don't have one
|
||||
if (threadID < 0) {
|
||||
val result = GroupManager.createPublicChatGroup(chat.id, context, null, chat.displayName)
|
||||
val result = GroupManager.createOpenGroup(chat.id, context, null, chat.displayName)
|
||||
threadID = result.threadId
|
||||
}
|
||||
DatabaseFactory.getLokiThreadDatabase(context).setPublicChat(chat, threadID)
|
||||
@@ -72,7 +72,7 @@ class LokiPublicChatManager(private val context: Context) {
|
||||
removedChatThreadIds.forEach { pollers.remove(it)?.stop() }
|
||||
|
||||
// Only append to chats if we have a thread for the chat
|
||||
chats = chatsInDB.filter { GroupManager.getPublicChatThreadId(it.value.id, context) > -1 }.toMutableMap()
|
||||
chats = chatsInDB.filter { GroupManager.getOpenGroupThreadID(it.value.id, context) > -1 }.toMutableMap()
|
||||
}
|
||||
|
||||
private fun listenToThreadDeletion(threadID: Long) {
|
||||
|
||||
@@ -15,7 +15,7 @@ object OpenGroupUtilities {
|
||||
@JvmStatic fun addGroup(context: Context, url: String, channel: Long): Promise<LokiPublicChat, Exception> {
|
||||
// Check for an existing group
|
||||
val groupID = LokiPublicChat.getId(channel, url)
|
||||
val threadID = GroupManager.getPublicChatThreadId(groupID, context)
|
||||
val threadID = GroupManager.getOpenGroupThreadID(groupID, context)
|
||||
val openGroup = DatabaseFactory.getLokiThreadDatabase(context).getPublicChat(threadID)
|
||||
if (openGroup != null) { return Promise.of(openGroup) }
|
||||
// Add the new group
|
||||
|
||||
@@ -52,7 +52,7 @@ class UserView : LinearLayout {
|
||||
profilePictureView.additionalHexEncodedPublicKey = null
|
||||
profilePictureView.isRSSFeed = true
|
||||
} else {
|
||||
val threadID = GroupManager.getThreadIdFromGroupId(address, context)
|
||||
val threadID = GroupManager.getThreadIDFromGroupID(address, context)
|
||||
val users = MentionsManager.shared.userHexEncodedPublicKeyCache[threadID]?.toList() ?: listOf()
|
||||
val randomUsers = users.sorted() // Sort to provide a level of stability
|
||||
profilePictureView.hexEncodedPublicKey = randomUsers.getOrNull(0) ?: ""
|
||||
|
||||
Reference in New Issue
Block a user