mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-25 02:55:23 +00:00
wip: trying to track down failure to mark conversation as read in delayed group add
This commit is contained in:
parent
eb173d72e0
commit
dd001640a4
@ -228,12 +228,12 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
|
||||
return threadDb.getLastSeenAndHasSent(threadId)?.first() ?: 0L
|
||||
}
|
||||
|
||||
override fun markConversationAsRead(threadId: Long, lastSeenTime: Long) {
|
||||
override fun markConversationAsRead(threadId: Long, lastSeenTime: Long, force: Boolean) {
|
||||
val threadDb = DatabaseComponent.get(context).threadDatabase()
|
||||
getRecipientForThread(threadId)?.let { recipient ->
|
||||
val currentLastRead = threadDb.getLastSeenAndHasSent(threadId).first()
|
||||
// don't set the last read in the volatile if we didn't set it in the DB
|
||||
if (!threadDb.markAllAsRead(threadId, recipient.isGroupRecipient, lastSeenTime)) return
|
||||
if (!threadDb.markAllAsRead(threadId, recipient.isGroupRecipient, lastSeenTime, force) && !force) return
|
||||
|
||||
// don't process configs for inbox recipients
|
||||
if (recipient.isOpenGroupInboxRecipient) return
|
||||
@ -500,11 +500,11 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
|
||||
val threadId = when (conversation) {
|
||||
is Conversation.OneToOne -> getThreadIdFor(conversation.sessionId, null, null, createThread = false)
|
||||
is Conversation.LegacyGroup -> getThreadIdFor("", conversation.groupId,null, createThread = false)
|
||||
is Conversation.Community -> getThreadIdFor("",null, "${conversation.baseCommunityInfo.baseUrl}.${conversation.baseCommunityInfo.room}", createThread = false)
|
||||
is Conversation.Community -> getThreadIdFor("",null, "${conversation.baseCommunityInfo.baseUrl.removeSuffix("/")}.${conversation.baseCommunityInfo.room}", createThread = false)
|
||||
}
|
||||
if (threadId != null) {
|
||||
if (conversation.lastRead > getLastSeen(threadId)) {
|
||||
markConversationAsRead(threadId, conversation.lastRead)
|
||||
markConversationAsRead(threadId, conversation.lastRead, force = true)
|
||||
}
|
||||
updateThread(threadId, false)
|
||||
}
|
||||
@ -1040,7 +1040,7 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
|
||||
val volatile = volatileConfig.getOrConstructCommunity(infoServer, infoRoom, pubKey)
|
||||
if (volatile.lastRead != 0L) {
|
||||
val threadId = getThreadId(openGroup) ?: return
|
||||
markConversationAsRead(threadId, volatile.lastRead)
|
||||
markConversationAsRead(threadId, volatile.lastRead, force = true)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -812,9 +812,9 @@ public class ThreadDatabase extends Database {
|
||||
* @param lastSeenTime
|
||||
* @return true if we have set the last seen for the thread, false if there were no messages in the thread
|
||||
*/
|
||||
public boolean markAllAsRead(long threadId, boolean isGroupRecipient, long lastSeenTime) {
|
||||
public boolean markAllAsRead(long threadId, boolean isGroupRecipient, long lastSeenTime, boolean force) {
|
||||
MmsSmsDatabase mmsSmsDatabase = DatabaseComponent.get(context).mmsSmsDatabase();
|
||||
if (mmsSmsDatabase.getConversationCount(threadId) <= 0) return false;
|
||||
if (mmsSmsDatabase.getConversationCount(threadId) <= 0 && !force) return false;
|
||||
List<MarkedMessageInfo> messages = setRead(threadId, lastSeenTime);
|
||||
if (isGroupRecipient) {
|
||||
for (MarkedMessageInfo message: messages) {
|
||||
|
@ -57,7 +57,7 @@ public class MarkReadReceiver extends BroadcastReceiver {
|
||||
for (long threadId : threadIds) {
|
||||
Log.i(TAG, "Marking as read: " + threadId);
|
||||
StorageProtocol storage = MessagingModuleConfiguration.getShared().getStorage();
|
||||
storage.markConversationAsRead(threadId,currentTime);
|
||||
storage.markConversationAsRead(threadId,currentTime, true);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ interface StorageProtocol {
|
||||
* Returns the ID of the `TSIncomingMessage` that was constructed.
|
||||
*/
|
||||
fun persist(message: VisibleMessage, quotes: QuoteModel?, linkPreview: List<LinkPreview?>, groupPublicKey: String?, openGroupID: String?, attachments: List<Attachment>, runThreadUpdate: Boolean): Long?
|
||||
fun markConversationAsRead(threadId: Long, lastSeenTime: Long)
|
||||
fun markConversationAsRead(threadId: Long, lastSeenTime: Long, force: Boolean = false)
|
||||
fun getLastSeen(threadId: Long): Long
|
||||
fun updateThread(threadId: Long, unarchive: Boolean)
|
||||
fun insertDataExtractionNotificationMessage(senderPublicKey: String, message: DataExtractionNotificationInfoMessage, sentTimestamp: Long)
|
||||
|
@ -28,6 +28,7 @@ class BackgroundGroupAddJob(val joinUrl: String): Job {
|
||||
}
|
||||
|
||||
override suspend fun execute(dispatcherName: String) {
|
||||
Log.d("Loki-DBG", "adding group $joinUrl")
|
||||
try {
|
||||
val openGroup = OpenGroupUrlParser.parseUrl(joinUrl)
|
||||
val storage = MessagingModuleConfiguration.shared.storage
|
||||
|
Loading…
Reference in New Issue
Block a user