Fix issue when refreshing notifications + fix an issue with cache and DM

maths
Thomas 2 years ago
parent 468f825dc0
commit 65156e0a84

@ -140,7 +140,7 @@ public class FragmentMastodonConversation extends Fragment implements Conversati
timelineParams.fetchingMissing = fetchingMissing; timelineParams.fetchingMissing = fetchingMissing;
if (useCache) { if (useCache && direction != FragmentMastodonTimeline.DIRECTION.SCROLL_TOP && direction != FragmentMastodonTimeline.DIRECTION.FETCH_NEW) {
getCachedConversations(direction, fetchingMissing, timelineParams); getCachedConversations(direction, fetchingMissing, timelineParams);
} else { } else {
getLiveConversations(direction, fetchingMissing, timelineParams, conversationToUpdate); getLiveConversations(direction, fetchingMissing, timelineParams, conversationToUpdate);
@ -150,7 +150,7 @@ public class FragmentMastodonConversation extends Fragment implements Conversati
private void getCachedConversations(FragmentMastodonTimeline.DIRECTION direction, boolean fetchingMissing, TimelinesVM.TimelineParams timelineParams) { private void getCachedConversations(FragmentMastodonTimeline.DIRECTION direction, boolean fetchingMissing, TimelinesVM.TimelineParams timelineParams) {
if (direction == null) { if (direction == null) {
timelinesVM.getConversations(conversationList, timelineParams) timelinesVM.getConversationsCache(conversationList, timelineParams)
.observe(getViewLifecycleOwner(), conversationsCached -> { .observe(getViewLifecycleOwner(), conversationsCached -> {
if (conversationsCached == null || conversationsCached.conversations == null || conversationsCached.conversations.size() == 0) { if (conversationsCached == null || conversationsCached.conversations == null || conversationsCached.conversations.size() == 0) {
getLiveConversations(null, fetchingMissing, timelineParams, null); getLiveConversations(null, fetchingMissing, timelineParams, null);
@ -179,13 +179,18 @@ public class FragmentMastodonConversation extends Fragment implements Conversati
} }
}); });
} else if (direction == FragmentMastodonTimeline.DIRECTION.REFRESH) { } else if (direction == FragmentMastodonTimeline.DIRECTION.REFRESH) {
timelinesVM.getConversations(conversationList, timelineParams) timelinesVM.getConversationsCache(conversationList, timelineParams)
.observe(getViewLifecycleOwner(), notificationsRefresh -> { .observe(getViewLifecycleOwner(), notificationsRefresh -> {
if (conversationAdapter != null) { if (notificationsRefresh == null || notificationsRefresh.conversations == null || notificationsRefresh.conversations.size() == 0) {
dealWithPagination(notificationsRefresh, FragmentMastodonTimeline.DIRECTION.REFRESH, true, null); getLiveConversations(direction, fetchingMissing, timelineParams, null);
} else { } else {
initializeConversationCommonView(notificationsRefresh); if (conversationAdapter != null) {
dealWithPagination(notificationsRefresh, FragmentMastodonTimeline.DIRECTION.REFRESH, true, null);
} else {
initializeConversationCommonView(notificationsRefresh);
}
} }
}); });
} }
} }

@ -387,7 +387,7 @@ public class FragmentMastodonNotification extends Fragment implements Notificati
} }
timelineParams.excludeType = getExcludeType(); timelineParams.excludeType = getExcludeType();
timelineParams.fetchingMissing = fetchingMissing; timelineParams.fetchingMissing = fetchingMissing;
if (useCache) { if (useCache && direction != FragmentMastodonTimeline.DIRECTION.SCROLL_TOP && direction != FragmentMastodonTimeline.DIRECTION.FETCH_NEW) {
getCachedNotifications(direction, fetchingMissing, timelineParams); getCachedNotifications(direction, fetchingMissing, timelineParams);
} else { } else {
getLiveNotifications(direction, fetchingMissing, timelineParams, notificationToUpdate); getLiveNotifications(direction, fetchingMissing, timelineParams, notificationToUpdate);
@ -430,10 +430,14 @@ public class FragmentMastodonNotification extends Fragment implements Notificati
} else if (direction == FragmentMastodonTimeline.DIRECTION.REFRESH) { } else if (direction == FragmentMastodonTimeline.DIRECTION.REFRESH) {
notificationsVM.getNotifications(notificationList, timelineParams) notificationsVM.getNotifications(notificationList, timelineParams)
.observe(getViewLifecycleOwner(), notificationsRefresh -> { .observe(getViewLifecycleOwner(), notificationsRefresh -> {
if (notificationAdapter != null) { if (notificationsRefresh == null || notificationsRefresh.notifications == null || notificationsRefresh.notifications.size() == 0) {
dealWithPagination(notificationsRefresh, FragmentMastodonTimeline.DIRECTION.REFRESH, true, null); getLiveNotifications(direction, fetchingMissing, timelineParams, null);
} else { } else {
initializeNotificationView(notificationsRefresh); if (notificationAdapter != null) {
dealWithPagination(notificationsRefresh, FragmentMastodonTimeline.DIRECTION.REFRESH, true, null);
} else {
initializeNotificationView(notificationsRefresh);
}
} }
}); });
} }

Loading…
Cancel
Save