Fixes #4286 - Contributions didn't appear after logging in again (#4337)

* fix the issue with contributions not appearing after logging in again

* fix old contribution appearing on top

Co-authored-by: Pratham2305 <Pratham2305@users.noreply.github.com>
This commit is contained in:
Pratham Pahariya 2021-05-10 21:58:32 +05:30 committed by GitHub
parent 0fb2f1b7be
commit 2b62d8487b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 0 deletions

View file

@ -38,4 +38,15 @@ abstract class ContinuationClient<Network, Domain> {
continuationStore.remove("$prefix$category")
}
/**
* Remove the existing the key from continuationExists and continuationStore
*
* @param prefix
* @param userName the username
*/
protected fun resetUserContinuation(prefix: String, userName: String) {
continuationExists.remove("$prefix$userName")
continuationStore.remove("$prefix$userName")
}
}

View file

@ -27,6 +27,9 @@ class ContributionBoundaryCallback @Inject constructor(
* network
*/
override fun onZeroItemsLoaded() {
if (sessionManager.userName != null) {
mediaClient.resetUserNameContinuation(sessionManager.userName!!)
}
fetchContributions()
}
@ -66,6 +69,8 @@ class ContributionBoundaryCallback @Inject constructor(
)
}
)
}else {
compositeDisposable.clear()
}
}

View file

@ -50,6 +50,7 @@ public class DBOpenHelper extends SQLiteOpenHelper {
public void deleteTable(SQLiteDatabase db, String tableName) {
try {
db.execSQL(String.format(DROP_TABLE_STATEMENT, tableName));
onCreate(db);
} catch (SQLiteException e) {
e.printStackTrace();
}

View file

@ -149,6 +149,14 @@ class MediaClient @Inject constructor(
resetContinuation(CATEGORY_CONTINUATION_PREFIX, category)
}
/**
* Call the resetUserContinuation method
*
* @param userName the username
*/
fun resetUserNameContinuation(userName: String) =
resetUserContinuation("user_", userName)
override fun responseMapper(
networkResult: Single<MwQueryResponse>,
key: String?