Skip to content
This repository was archived by the owner on Oct 9, 2020. It is now read-only.

Fixes #2318 Events bookmarked from Featured Speakers are now visible in AboutFragment. #2329

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class AboutFragmentViewModel extends ViewModel {
private LiveData<Event> eventLiveData;
private LiveData<List<Speaker>> featuredSpeakers;
private MutableLiveData<Bitmap> eventLogo;
private Long numberOfBookmarkedSessions;

public AboutFragmentViewModel() {
realmRepo = RealmDataRepository.getDefaultInstance();
Expand All @@ -58,10 +59,12 @@ public List<String> getDateList() {
}

public LiveData<List<Object>> getBookmarkedSessions() {
if (sessions == null) {
if (sessions == null || numberOfBookmarkedSessions != realmRepo.getBookMarkedSessionsLength()) {
LiveRealmData<Session> sessionLiveRealmData = RealmDataRepository.asLiveData(realmRepo.getBookMarkedSessions());
sessions = Transformations.map(sessionLiveRealmData, this::getSessionsList);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

realmRepo.getBookMarkedSessions() these should be reactive and live and hence should be updated automatically

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But without going inside the if condition how the sessions object will be updated because we are returning sessions object. I added this condition "numberOfBookmarkedSessions != realmRepo.getBookMarkedSessionsLength()" so that the body of the if condition will be executed only when there is change in the realm.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I tried and changed the body of the if condition to this,

 if(sessions == null) {
      sessions = Transformations.map(RealmDataRepository.asLiveData(realmRepo.getBookMarkedSessions()),this::getSessionsList);
   }  

I changed this because realmRepo.getBookMarkedSessions() should be executed if the object is auto updated but still after changing the code to this sessions object returns the old list.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend that you actually try to get bookmarked sessions from RealmRepository and add a listener on them and check if you are getting change event or not. This will reveal the problem

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@srv-twry The changes you mentioned are the only changes that needed to be done?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, they are the only changes that i made.
The error you're getting is weird. Can you completely uninstall the application and reinstall it after making the above changes ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am still getting the same results. I also noticed one thing that when you install the app so you are basically logged out (now don't login) and then if you try to bookmark the events, the events don't get displayed at all in AboutFragment.java, doesn't matter how many events you bookmark. Are you getting the same results too when you install the app and you are logged out? I am using Android 7.0 Nougat (API 24).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above GIF that i uploaded has me logged out only.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I'll try to see why am I getting these errors. As I cleared the cache data and uninstalled the application and then installed it with your suggested changes. I have my development branch updated with the remote branch. And still I am getting these errors. I'll see why am I getting these errors and will notify you soon.

numberOfBookmarkedSessions = realmRepo.getBookMarkedSessionsLength();
}

return sessions;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,10 @@ public RealmResults<Session> getBookMarkedSessions() {
return realm.where(Session.class).equalTo("isBookmarked", true).findAllAsync();
}

public long getBookMarkedSessionsLength() {
return realm.where(Session.class).equalTo("isBookmarked", true).count();
}

public List<Session> getBookMarkedSessionsSync() {
Realm realm = Realm.getDefaultInstance();
RealmResults<Session> sessions = realm.where(Session.class).equalTo("isBookmarked", true).findAll();
Expand Down