mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-25 11:05:25 +00:00
fix: pinned status for communities and groups, group last read time being set to snodeapi.now on finish joining
This commit is contained in:
parent
c777c05456
commit
8e5a810135
@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.database
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import network.loki.messenger.libsession_util.ConfigBase
|
||||
import network.loki.messenger.libsession_util.ConfigBase.Companion.PRIORITY_PINNED
|
||||
import network.loki.messenger.libsession_util.Contacts
|
||||
import network.loki.messenger.libsession_util.ConversationVolatileConfig
|
||||
import network.loki.messenger.libsession_util.UserGroupsConfig
|
||||
@ -521,10 +522,10 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
|
||||
if (groupBaseCommunity.fullUrl() !in existingJoinUrls) {
|
||||
// add it
|
||||
val (threadId, _) = OpenGroupManager.add(groupBaseCommunity.baseUrl, groupBaseCommunity.room, groupBaseCommunity.pubKeyHex, context)
|
||||
threadDb.setPinned(threadId, groupInfo.priority >= 1)
|
||||
threadDb.setPinned(threadId, groupInfo.priority == PRIORITY_PINNED)
|
||||
} else {
|
||||
val (threadId, _) = existingCommunities.entries.first { (_, v) -> v.joinURL == groupInfo.community.fullUrl() }
|
||||
threadDb.setPinned(threadId, groupInfo.priority >= 1)
|
||||
threadDb.setPinned(threadId, groupInfo.priority == PRIORITY_PINNED)
|
||||
}
|
||||
}
|
||||
|
||||
@ -962,9 +963,7 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
|
||||
val pubKeyHex = Hex.toStringCondensed(pubKey)
|
||||
val communityInfo = groups.getOrConstructCommunityInfo(infoServer, infoRoom, pubKeyHex)
|
||||
groups.set(communityInfo)
|
||||
val volatile = volatileConfig.getOrConstructCommunity(infoServer, infoRoom, pubKey).copy(
|
||||
lastRead = SnodeAPI.nowWithOffset,
|
||||
)
|
||||
val volatile = volatileConfig.getOrConstructCommunity(infoServer, infoRoom, pubKey)
|
||||
volatileConfig.set(volatile)
|
||||
}
|
||||
|
||||
@ -1087,6 +1086,10 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
|
||||
getThreadId(fromSerialized(contact.id))?.let { conversationThreadId ->
|
||||
deleteConversation(conversationThreadId)
|
||||
}
|
||||
} else {
|
||||
getThreadId(fromSerialized(contact.id))?.let { conversationThreadId ->
|
||||
setPinned(conversationThreadId, contact.priority == ConfigBase.PRIORITY_PINNED)
|
||||
}
|
||||
}
|
||||
Log.d("Loki-DBG", "Updated contact $contact")
|
||||
}
|
||||
|
@ -528,6 +528,10 @@ public class ThreadDatabase extends Database {
|
||||
|
||||
public void setLastSeen(long threadId, long timestamp) {
|
||||
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
||||
|
||||
// edge case where we set the last seen time for a conversation before it loads messages (joining community for example)
|
||||
if (getMessageCount(threadId) <= 0) return;
|
||||
|
||||
ContentValues contentValues = new ContentValues(1);
|
||||
long lastSeenTime = timestamp == -1 ? SnodeAPI.getNowWithOffset() : timestamp;
|
||||
contentValues.put(LAST_SEEN, lastSeenTime);
|
||||
|
Loading…
Reference in New Issue
Block a user