Only clear feed from the right user
This commit is contained in:
parent
ea2c9bc6db
commit
ebec547dd0
|
@ -73,7 +73,7 @@ class NotificationsRemoteMediator @Inject constructor(
|
||||||
db.withTransaction {
|
db.withTransaction {
|
||||||
// clear table in the database
|
// clear table in the database
|
||||||
if (loadType == LoadType.REFRESH) {
|
if (loadType == LoadType.REFRESH) {
|
||||||
db.notificationDao().clearFeedContent()
|
db.notificationDao().clearFeedContent(user.user_id, user.instance_uri)
|
||||||
}
|
}
|
||||||
db.notificationDao().insertAll(apiResponse)
|
db.notificationDao().insertAll(apiResponse)
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ class HomeFeedRemoteMediator @Inject constructor(
|
||||||
db.withTransaction {
|
db.withTransaction {
|
||||||
// clear table in the database
|
// clear table in the database
|
||||||
if (loadType == LoadType.REFRESH) {
|
if (loadType == LoadType.REFRESH) {
|
||||||
db.homePostDao().clearFeedContent()
|
db.homePostDao().clearFeedContent(user.user_id, user.instance_uri)
|
||||||
}
|
}
|
||||||
db.homePostDao().insertAll(dbObjects)
|
db.homePostDao().insertAll(dbObjects)
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ class PublicFeedRemoteMediator @Inject constructor(
|
||||||
db.withTransaction {
|
db.withTransaction {
|
||||||
// clear table in the database
|
// clear table in the database
|
||||||
if (loadType == LoadType.REFRESH) {
|
if (loadType == LoadType.REFRESH) {
|
||||||
db.publicPostDao().clearFeedContent()
|
db.publicPostDao().clearFeedContent(user.user_id, user.instance_uri)
|
||||||
}
|
}
|
||||||
db.publicPostDao().insertAll(dbObjects)
|
db.publicPostDao().insertAll(dbObjects)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ interface FeedContentDao<T: FeedContentDatabase>{
|
||||||
|
|
||||||
fun feedContent(userId: String, instanceUri: String): PagingSource<Int, T>
|
fun feedContent(userId: String, instanceUri: String): PagingSource<Int, T>
|
||||||
|
|
||||||
suspend fun clearFeedContent()
|
suspend fun clearFeedContent(userId: String, instanceUri: String)
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
suspend fun insertAll(feedContent: List<T>)
|
suspend fun insertAll(feedContent: List<T>)
|
||||||
|
|
|
@ -8,8 +8,8 @@ import org.pixeldroid.app.utils.api.objects.Notification
|
||||||
@Dao
|
@Dao
|
||||||
interface NotificationDao: FeedContentDao<Notification> {
|
interface NotificationDao: FeedContentDao<Notification> {
|
||||||
|
|
||||||
@Query("DELETE FROM notifications")
|
@Query("DELETE FROM notifications WHERE user_id=:userId AND instance_uri=:instanceUri")
|
||||||
override suspend fun clearFeedContent()
|
override suspend fun clearFeedContent(userId: String, instanceUri: String)
|
||||||
|
|
||||||
@Query("""SELECT * FROM notifications WHERE user_id=:userId AND instance_uri=:instanceUri
|
@Query("""SELECT * FROM notifications WHERE user_id=:userId AND instance_uri=:instanceUri
|
||||||
ORDER BY CAST(created_at AS FLOAT) DESC""")
|
ORDER BY CAST(created_at AS FLOAT) DESC""")
|
||||||
|
|
|
@ -12,8 +12,8 @@ interface HomePostDao: FeedContentDao<HomeStatusDatabaseEntity> {
|
||||||
ORDER BY CAST(created_at AS FLOAT)""")
|
ORDER BY CAST(created_at AS FLOAT)""")
|
||||||
override fun feedContent(userId: String, instanceUri: String): PagingSource<Int, HomeStatusDatabaseEntity>
|
override fun feedContent(userId: String, instanceUri: String): PagingSource<Int, HomeStatusDatabaseEntity>
|
||||||
|
|
||||||
@Query("DELETE FROM homePosts")
|
@Query("DELETE FROM homePosts WHERE user_id=:userId AND instance_uri=:instanceUri")
|
||||||
override suspend fun clearFeedContent()
|
override suspend fun clearFeedContent(userId: String, instanceUri: String)
|
||||||
|
|
||||||
@Query("DELETE FROM homePosts WHERE user_id=:userId AND instance_uri=:instanceUri AND id=:id")
|
@Query("DELETE FROM homePosts WHERE user_id=:userId AND instance_uri=:instanceUri AND id=:id")
|
||||||
override suspend fun delete(id: String, userId: String, instanceUri: String)
|
override suspend fun delete(id: String, userId: String, instanceUri: String)
|
||||||
|
|
|
@ -12,8 +12,8 @@ interface PublicPostDao: FeedContentDao<PublicFeedStatusDatabaseEntity> {
|
||||||
ORDER BY CAST(created_at AS FLOAT)""")
|
ORDER BY CAST(created_at AS FLOAT)""")
|
||||||
override fun feedContent(userId: String, instanceUri: String): PagingSource<Int, PublicFeedStatusDatabaseEntity>
|
override fun feedContent(userId: String, instanceUri: String): PagingSource<Int, PublicFeedStatusDatabaseEntity>
|
||||||
|
|
||||||
@Query("DELETE FROM publicPosts")
|
@Query("DELETE FROM publicPosts WHERE user_id=:userId AND instance_uri=:instanceUri")
|
||||||
override suspend fun clearFeedContent()
|
override suspend fun clearFeedContent(userId: String, instanceUri: String)
|
||||||
|
|
||||||
@Query("DELETE FROM publicPosts WHERE user_id=:userId AND instance_uri=:instanceUri AND id=:id")
|
@Query("DELETE FROM publicPosts WHERE user_id=:userId AND instance_uri=:instanceUri AND id=:id")
|
||||||
override suspend fun delete(id: String, userId: String, instanceUri: String)
|
override suspend fun delete(id: String, userId: String, instanceUri: String)
|
||||||
|
|
Loading…
Reference in New Issue