fix: some open group volatile convo fix for last read timer being set. Need to investigate further

This commit is contained in:
0x330a 2023-04-24 17:33:02 +10:00
parent 8e5a810135
commit bba6eb0cc2
No known key found for this signature in database
GPG Key ID: 267811D6E6A2698C
5 changed files with 11 additions and 14 deletions

View File

@ -441,7 +441,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
// only update the conversation every 3 seconds maximum
// channel is rendezvous and shouldn't block on try send calls as often as we want
val bufferedFlow = bufferedLastSeenChannel.consumeAsFlow()
.debounce(1.seconds)
.debounce(30.seconds)
bufferedFlow.collectLatest {
withContext(Dispatchers.IO) {
storage.markConversationAsRead(viewModel.threadId, SnodeAPI.nowWithOffset)

View File

@ -93,10 +93,6 @@ import network.loki.messenger.libsession_util.util.Contact as LibSessionContact
open class Storage(context: Context, helper: SQLCipherOpenHelper, private val configFactory: ConfigFactory) : Database(context, helper), StorageProtocol,
ThreadDatabase.ConversationThreadUpdateListener {
init {
DatabaseComponent.get(context).threadDatabase().setUpdateListener(this)
}
// TODO: maybe add time here from formation / creation message
override fun threadCreated(address: Address, threadId: Long) {
if (!getRecipientApproved(address)) return // don't store unapproved / message requests
@ -131,9 +127,7 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
val userProfile = configFactory.user ?: return
userProfile.setNtsPriority(ConfigBase.PRIORITY_VISIBLE)
}
val newVolatileParams = volatile.getOrConstructOneToOne(address.serialize()).copy(
lastRead = SnodeAPI.nowWithOffset
)
val newVolatileParams = volatile.getOrConstructOneToOne(address.serialize())
volatile.set(newVolatileParams)
}
}
@ -964,7 +958,7 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
val communityInfo = groups.getOrConstructCommunityInfo(infoServer, infoRoom, pubKeyHex)
groups.set(communityInfo)
val volatile = volatileConfig.getOrConstructCommunity(infoServer, infoRoom, pubKey)
volatileConfig.set(volatile)
volatileConfig.set(volatile.copy(lastRead = 0))
}
override fun hasBackgroundGroupAddJob(groupJoinUrl: String): Boolean {
@ -1194,8 +1188,6 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
}
override fun deleteConversation(threadID: Long) {
// TODO: delete from either contacts / convo volatile or the closed groups
// TODO: message request deletion properly (not just doing a hidden priority)
val recipient = getRecipientForThread(threadID)
val threadDB = DatabaseComponent.get(context).threadDatabase()
threadDB.deleteConversation(threadID)

View File

@ -527,11 +527,11 @@ 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;
SQLiteDatabase db = databaseHelper.getWritableDatabase();
ContentValues contentValues = new ContentValues(1);
long lastSeenTime = timestamp == -1 ? SnodeAPI.getNowWithOffset() : timestamp;
contentValues.put(LAST_SEEN, lastSeenTime);

View File

@ -135,7 +135,11 @@ object DatabaseModule {
@Provides
@Singleton
fun provideStorage(@ApplicationContext context: Context, openHelper: SQLCipherOpenHelper, configFactory: ConfigFactory) = Storage(context,openHelper, configFactory)
fun provideStorage(@ApplicationContext context: Context, openHelper: SQLCipherOpenHelper, configFactory: ConfigFactory, threadDatabase: ThreadDatabase): Storage {
val storage = Storage(context,openHelper, configFactory)
threadDatabase.setUpdateListener(storage)
return storage
}
@Provides
@Singleton

View File

@ -119,6 +119,7 @@ object OpenGroupManager {
}
}
configFactory.userGroups?.eraseCommunity(server, room)
configFactory.convoVolatile?.eraseCommunity(server, room)
// Delete
storage.removeLastDeletionServerID(room, server)
storage.removeLastMessageServerID(room, server)