Fix conversations (#2556)
* fix conversations * cleanup ConversationsRemoteMediator * update conversation timestamps regularly * improve loadStateListener * add db migration * make deleting from conversation db suspending * reorganize code in ConversationsFragment * delete NetworkStateViewHolder * cleanup imports * add 38.json * honor fabHide setting in ConversationsFragment * set page size to 30
This commit is contained in:
parent
2983c3f48e
commit
131309e99c
14 changed files with 314 additions and 200 deletions
|
|
@ -565,10 +565,12 @@ public abstract class AppDatabase extends RoomDatabase {
|
|||
public static final Migration MIGRATION_37_38 = new Migration(37, 38) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||
|
||||
// no actual scheme change, but timestamps are now serialized differently so all cache tables that contain them need to be cleaned
|
||||
database.execSQL("DELETE FROM `TimelineStatusEntity`");
|
||||
// database needs to be cleaned because the ConversationAccountEntity got a new attribute
|
||||
database.execSQL("DELETE FROM `ConversationEntity`");
|
||||
database.execSQL("ALTER TABLE `ConversationEntity` ADD COLUMN `order` INTEGER NOT NULL DEFAULT 0");
|
||||
|
||||
// timestamps are now serialized differently so all cache tables that contain them need to be cleaned
|
||||
database.execSQL("DELETE FROM `TimelineStatusEntity`");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,14 +28,14 @@ interface ConversationsDao {
|
|||
suspend fun insert(conversations: List<ConversationEntity>)
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
suspend fun insert(conversation: ConversationEntity): Long
|
||||
suspend fun insert(conversation: ConversationEntity)
|
||||
|
||||
@Query("DELETE FROM ConversationEntity WHERE id = :id AND accountId = :accountId")
|
||||
suspend fun delete(id: String, accountId: Long): Int
|
||||
suspend fun delete(id: String, accountId: Long)
|
||||
|
||||
@Query("SELECT * FROM ConversationEntity WHERE accountId = :accountId ORDER BY s_createdAt DESC")
|
||||
@Query("SELECT * FROM ConversationEntity WHERE accountId = :accountId ORDER BY `order` ASC")
|
||||
fun conversationsForAccount(accountId: Long): PagingSource<Int, ConversationEntity>
|
||||
|
||||
@Query("DELETE FROM ConversationEntity WHERE accountId = :accountId")
|
||||
fun deleteForAccount(accountId: Long)
|
||||
suspend fun deleteForAccount(accountId: Long)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue