fix challenge loading.

This commit is contained in:
Phillip Thelen 2018-03-12 13:22:11 +01:00
parent ed38ca6000
commit afd3303256
3 changed files with 12 additions and 3 deletions

View file

@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.habitrpg.android.habitica"
android:versionCode="1974"
android:versionCode="1975"
android:versionName="1.4.3"
android:screenOrientation="portrait"
android:installLocation="auto" >

View file

@ -42,7 +42,7 @@ class RealmUserLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm),
removeOldTags(user.id, user.tags)
}
if (user.challenges != null) {
removeOldChallenges(user.id, user.challenges)
removeOldChallenges(user.challenges)
}
}
@ -56,7 +56,7 @@ class RealmUserLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm),
}
}
private fun removeOldChallenges(userId: String, onlineChallenges: List<Challenge>) {
private fun removeOldChallenges(onlineChallenges: List<Challenge>) {
val challenges = realm.where(Challenge::class.java).equalTo("isParticipating", true).findAll().createSnapshot()
val challengesToDelete = challenges.filterNot { onlineChallenges.contains(it) }
realm.executeTransaction {

View file

@ -1,5 +1,6 @@
package com.habitrpg.android.habitica.models.social;
import com.habitrpg.android.habitica.models.tasks.ChecklistItem;
import com.habitrpg.android.habitica.models.tasks.TasksOrder;
import com.habitrpg.android.habitica.models.user.User;
@ -64,4 +65,12 @@ public class Challenge extends RealmObject {
return map;
}
@Override
public boolean equals(Object obj) {
if (obj.getClass().equals(Challenge.class) && this.id != null) {
return this.id.equals(((Challenge)obj).id);
}
return super.equals(obj);
}
}