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.content.Context
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import network.loki.messenger.libsession_util.ConfigBase
|
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.Contacts
|
||||||
import network.loki.messenger.libsession_util.ConversationVolatileConfig
|
import network.loki.messenger.libsession_util.ConversationVolatileConfig
|
||||||
import network.loki.messenger.libsession_util.UserGroupsConfig
|
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) {
|
if (groupBaseCommunity.fullUrl() !in existingJoinUrls) {
|
||||||
// add it
|
// add it
|
||||||
val (threadId, _) = OpenGroupManager.add(groupBaseCommunity.baseUrl, groupBaseCommunity.room, groupBaseCommunity.pubKeyHex, context)
|
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 {
|
} else {
|
||||||
val (threadId, _) = existingCommunities.entries.first { (_, v) -> v.joinURL == groupInfo.community.fullUrl() }
|
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 pubKeyHex = Hex.toStringCondensed(pubKey)
|
||||||
val communityInfo = groups.getOrConstructCommunityInfo(infoServer, infoRoom, pubKeyHex)
|
val communityInfo = groups.getOrConstructCommunityInfo(infoServer, infoRoom, pubKeyHex)
|
||||||
groups.set(communityInfo)
|
groups.set(communityInfo)
|
||||||
val volatile = volatileConfig.getOrConstructCommunity(infoServer, infoRoom, pubKey).copy(
|
val volatile = volatileConfig.getOrConstructCommunity(infoServer, infoRoom, pubKey)
|
||||||
lastRead = SnodeAPI.nowWithOffset,
|
|
||||||
)
|
|
||||||
volatileConfig.set(volatile)
|
volatileConfig.set(volatile)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1087,6 +1086,10 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
|
|||||||
getThreadId(fromSerialized(contact.id))?.let { conversationThreadId ->
|
getThreadId(fromSerialized(contact.id))?.let { conversationThreadId ->
|
||||||
deleteConversation(conversationThreadId)
|
deleteConversation(conversationThreadId)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
getThreadId(fromSerialized(contact.id))?.let { conversationThreadId ->
|
||||||
|
setPinned(conversationThreadId, contact.priority == ConfigBase.PRIORITY_PINNED)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Log.d("Loki-DBG", "Updated contact $contact")
|
Log.d("Loki-DBG", "Updated contact $contact")
|
||||||
}
|
}
|
||||||
|
@ -528,6 +528,10 @@ public class ThreadDatabase extends Database {
|
|||||||
|
|
||||||
public void setLastSeen(long threadId, long timestamp) {
|
public void setLastSeen(long threadId, long timestamp) {
|
||||||
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
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);
|
ContentValues contentValues = new ContentValues(1);
|
||||||
long lastSeenTime = timestamp == -1 ? SnodeAPI.getNowWithOffset() : timestamp;
|
long lastSeenTime = timestamp == -1 ? SnodeAPI.getNowWithOffset() : timestamp;
|
||||||
contentValues.put(LAST_SEEN, lastSeenTime);
|
contentValues.put(LAST_SEEN, lastSeenTime);
|
||||||
|
Loading…
Reference in New Issue
Block a user