mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 16:50:04 +02:00
Fix empty Home when starting
This commit is contained in:
parent
cb2ede287d
commit
37838681da
2 changed files with 17 additions and 6 deletions
|
@ -386,27 +386,27 @@ public class NotificationsHelper {
|
|||
@Override
|
||||
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
|
||||
String lastNotif = prefs.getString(context.getString(R.string.LAST_NOTIFICATION_ID) + account.user_id + "@" + account.instance, null);
|
||||
if (lastNotif == null || Helper.compareTo(notification.id, lastNotif) > 0) {
|
||||
// if (lastNotif == null || Helper.compareTo(notification.id, lastNotif) > 0) {
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
editor.putString(context.getString(R.string.LAST_NOTIFICATION_ID) + account.user_id + "@" + account.instance, notifications.get(0).id);
|
||||
editor.commit();
|
||||
since_ids.put(account.user_id + "@" + account.instance, lastNotif);
|
||||
Helper.notify_user(context, account, intent, resource, finalNotifType, finalTitle, finalMessage);
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed(@Nullable Drawable errorDrawable) {
|
||||
super.onLoadFailed(errorDrawable);
|
||||
String lastNotif = prefs.getString(context.getString(R.string.LAST_NOTIFICATION_ID) + account.user_id + "@" + account.instance, null);
|
||||
if (lastNotif == null || Helper.compareTo(notification.id, lastNotif) > 0) {
|
||||
// if (lastNotif == null || Helper.compareTo(notification.id, lastNotif) > 0) {
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
since_ids.put(account.user_id + "@" + account.instance, lastNotif);
|
||||
editor.putString(context.getString(R.string.LAST_NOTIFICATION_ID) + account.user_id + "@" + account.instance, notifications.get(0).id);
|
||||
editor.commit();
|
||||
Helper.notify_user(context, account, intent, BitmapFactory.decodeResource(context.getResources(),
|
||||
getMainLogo(context)), finalNotifType, finalTitle, finalMessage);
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -87,6 +87,9 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
private StatusAdapter statusAdapter;
|
||||
private Timeline.TimeLineEnum timelineType;
|
||||
private List<Status> timelineStatuses;
|
||||
|
||||
private boolean retry_for_home_done;
|
||||
|
||||
//Handle actions that can be done in other fragments
|
||||
private final BroadcastReceiver receive_action = new BroadcastReceiver() {
|
||||
@Override
|
||||
|
@ -376,6 +379,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
ViewGroup container, Bundle savedInstanceState) {
|
||||
timelineType = Timeline.TimeLineEnum.HOME;
|
||||
canBeFederated = true;
|
||||
retry_for_home_done = false;
|
||||
if (getArguments() != null) {
|
||||
timelineType = (Timeline.TimeLineEnum) getArguments().get(Helper.ARG_TIMELINE_TYPE);
|
||||
list_id = getArguments().getString(Helper.ARG_LIST_ID, null);
|
||||
|
@ -794,6 +798,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
boolean useCache = sharedpreferences.getBoolean(getString(R.string.SET_USE_CACHE), true);
|
||||
if (useCache && direction != DIRECTION.SCROLL_TOP && direction != DIRECTION.FETCH_NEW) {
|
||||
getCachedStatus(direction, fetchingMissing, timelineParams, fetchStatus);
|
||||
|
||||
} else {
|
||||
getLiveStatus(direction, fetchingMissing, timelineParams, true, fetchStatus);
|
||||
}
|
||||
|
@ -855,7 +860,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
}
|
||||
|
||||
private void getCachedStatus(DIRECTION direction, boolean fetchingMissing, TimelinesVM.TimelineParams timelineParams, Status fetchStatus) {
|
||||
|
||||
if (direction == null) {
|
||||
timelinesVM.getTimelineCache(timelineStatuses, timelineParams)
|
||||
.observe(getViewLifecycleOwner(), statusesCached -> {
|
||||
|
@ -913,7 +917,14 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
timelinesVM.getTimeline(timelineStatuses, timelineParams)
|
||||
.observe(getViewLifecycleOwner(), statuses -> {
|
||||
initialStatuses = statuses;
|
||||
initializeStatusesCommonView(statuses);
|
||||
if (!retry_for_home_done && timelineType == Timeline.TimeLineEnum.HOME && (statuses == null || statuses.statuses.size() == 0) && timelineParams.maxId != null) {
|
||||
retry_for_home_done = true;
|
||||
timelineParams.maxId = null;
|
||||
max_id = null;
|
||||
getLiveStatus(null, fetchingMissing, timelineParams, true, fetchStatus);
|
||||
} else {
|
||||
initializeStatusesCommonView(statuses);
|
||||
}
|
||||
});
|
||||
} else if (direction == DIRECTION.BOTTOM) {
|
||||
timelinesVM.getTimeline(timelineStatuses, timelineParams)
|
||||
|
|
Loading…
Reference in a new issue