mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 16:50:04 +02:00
Fix empty timelines after GB
This commit is contained in:
parent
29995fc219
commit
b12f9f2ded
4 changed files with 13 additions and 5 deletions
|
@ -124,7 +124,7 @@ public class FragmentMastodonConversation extends Fragment implements Conversati
|
|||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
|
||||
boolean useCache = sharedpreferences.getBoolean(getString(R.string.SET_USE_CACHE), true);
|
||||
|
||||
TimelinesVM.TimelineParams timelineParams = new TimelinesVM.TimelineParams(Timeline.TimeLineEnum.NOTIFICATION, direction, null);
|
||||
TimelinesVM.TimelineParams timelineParams = new TimelinesVM.TimelineParams(requireActivity(), Timeline.TimeLineEnum.NOTIFICATION, direction, null);
|
||||
timelineParams.limit = MastodonHelper.notificationsPerCall(requireActivity());
|
||||
if (direction == FragmentMastodonTimeline.DIRECTION.REFRESH || direction == FragmentMastodonTimeline.DIRECTION.SCROLL_TOP) {
|
||||
timelineParams.maxId = null;
|
||||
|
|
|
@ -314,7 +314,6 @@ public class FragmentMastodonNotification extends Fragment implements Notificati
|
|||
mLayoutManager = new LinearLayoutManager(requireActivity());
|
||||
binding.recyclerView.setLayoutManager(mLayoutManager);
|
||||
binding.recyclerView.setAdapter(notificationAdapter);
|
||||
|
||||
binding.recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
||||
|
@ -390,7 +389,7 @@ public class FragmentMastodonNotification extends Fragment implements Notificati
|
|||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
|
||||
boolean useCache = sharedpreferences.getBoolean(getString(R.string.SET_USE_CACHE), true);
|
||||
|
||||
TimelinesVM.TimelineParams timelineParams = new TimelinesVM.TimelineParams(Timeline.TimeLineEnum.NOTIFICATION, direction, null);
|
||||
TimelinesVM.TimelineParams timelineParams = new TimelinesVM.TimelineParams(requireActivity(), Timeline.TimeLineEnum.NOTIFICATION, direction, null);
|
||||
timelineParams.limit = MastodonHelper.notificationsPerCall(requireActivity());
|
||||
if (direction == FragmentMastodonTimeline.DIRECTION.REFRESH || direction == FragmentMastodonTimeline.DIRECTION.SCROLL_TOP) {
|
||||
timelineParams.maxId = null;
|
||||
|
@ -406,6 +405,7 @@ public class FragmentMastodonNotification extends Fragment implements Notificati
|
|||
}
|
||||
timelineParams.excludeType = getExcludeType();
|
||||
timelineParams.fetchingMissing = fetchingMissing;
|
||||
|
||||
if (useCache && direction != FragmentMastodonTimeline.DIRECTION.SCROLL_TOP && direction != FragmentMastodonTimeline.DIRECTION.FETCH_NEW) {
|
||||
getCachedNotifications(direction, fetchingMissing, timelineParams);
|
||||
} else {
|
||||
|
|
|
@ -757,7 +757,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
return;
|
||||
}
|
||||
//Initialize with default params
|
||||
TimelinesVM.TimelineParams timelineParams = new TimelinesVM.TimelineParams(timelineType, direction, ident);
|
||||
TimelinesVM.TimelineParams timelineParams = new TimelinesVM.TimelineParams(requireActivity(), timelineType, direction, ident);
|
||||
timelineParams.limit = MastodonHelper.statusesPerCall(requireActivity());
|
||||
if (direction == DIRECTION.REFRESH || direction == DIRECTION.SCROLL_TOP || direction == DIRECTION.FETCH_NEW) {
|
||||
timelineParams.maxId = null;
|
||||
|
|
|
@ -15,6 +15,9 @@ package app.fedilab.android.mastodon.viewmodel.mastodon;
|
|||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
|
||||
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_ID;
|
||||
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_INSTANCE;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
@ -968,11 +971,16 @@ public class TimelinesVM extends AndroidViewModel {
|
|||
public List<String> excludeVisibilities;
|
||||
public String replyVisibility;
|
||||
|
||||
public TimelineParams(@NonNull Timeline.TimeLineEnum timeLineEnum, @Nullable FragmentMastodonTimeline.DIRECTION timelineDirection, @Nullable String ident) {
|
||||
public TimelineParams(Context context, @NonNull Timeline.TimeLineEnum timeLineEnum, @Nullable FragmentMastodonTimeline.DIRECTION timelineDirection, @Nullable String ident) {
|
||||
if (type != Timeline.TimeLineEnum.REMOTE) {
|
||||
instance = MainActivity.currentInstance;
|
||||
token = MainActivity.currentToken;
|
||||
userId = MainActivity.currentUserID;
|
||||
if (instance == null || userId == null) {
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
instance = sharedpreferences.getString(PREF_USER_INSTANCE, null);
|
||||
userId = sharedpreferences.getString(PREF_USER_ID, null);
|
||||
}
|
||||
}
|
||||
type = timeLineEnum;
|
||||
direction = timelineDirection;
|
||||
|
|
Loading…
Reference in a new issue