mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2025-01-07 00:20:08 +02:00
Fix an issue with cache and home TL
This commit is contained in:
parent
cfb3c42839
commit
ed3579ba65
2 changed files with 9 additions and 9 deletions
|
@ -906,11 +906,11 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
} else {
|
||||
max_id = null;
|
||||
}
|
||||
timelinesVM.getHome(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, false, max_id, null, null, MastodonHelper.statusesPerCall(requireActivity()), false)
|
||||
timelinesVM.getHome(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, BaseMainActivity.currentUserID, false, max_id, null, null, MastodonHelper.statusesPerCall(requireActivity()), false)
|
||||
.observe(getViewLifecycleOwner(), this::initializeStatusesCommonView);
|
||||
});
|
||||
} else {
|
||||
timelinesVM.getHome(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, false, max_id, null, null, MastodonHelper.statusesPerCall(requireActivity()), false)
|
||||
timelinesVM.getHome(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, BaseMainActivity.currentUserID, false, max_id, null, null, MastodonHelper.statusesPerCall(requireActivity()), false)
|
||||
.observe(getViewLifecycleOwner(), this::initializeStatusesCommonView);
|
||||
}
|
||||
|
||||
|
@ -932,7 +932,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
if (statusesBottomCache != null && statusesBottomCache.statuses != null && statusesBottomCache.statuses.size() > 0) {
|
||||
dealWithPagination(statusesBottomCache, DIRECTION.BOTTOM, false);
|
||||
} else { // If not, we fetch remotely
|
||||
timelinesVM.getHome(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, false, max_id, null, null, MastodonHelper.statusesPerCall(requireActivity()), false)
|
||||
timelinesVM.getHome(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, BaseMainActivity.currentUserID, false, max_id, null, null, MastodonHelper.statusesPerCall(requireActivity()), false)
|
||||
.observe(getViewLifecycleOwner(), statusesBottom -> dealWithPagination(statusesBottom, DIRECTION.BOTTOM, false));
|
||||
}
|
||||
});
|
||||
|
@ -942,7 +942,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
.observe(getViewLifecycleOwner(), statusesBottom -> dealWithPagination(statusesBottom, DIRECTION.BOTTOM, false));
|
||||
}
|
||||
} else {
|
||||
timelinesVM.getHome(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, true, max_id_fetch_more, null, null, MastodonHelper.statusesPerCall(requireActivity()), false)
|
||||
timelinesVM.getHome(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, BaseMainActivity.currentUserID, true, max_id_fetch_more, null, null, MastodonHelper.statusesPerCall(requireActivity()), false)
|
||||
.observe(getViewLifecycleOwner(), statusesBottom -> dealWithPagination(statusesBottom, DIRECTION.BOTTOM, true));
|
||||
}
|
||||
} else if (direction == DIRECTION.TOP) {
|
||||
|
@ -953,7 +953,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
if (statusesTopCache != null && statusesTopCache.statuses != null && statusesTopCache.statuses.size() > 0) {
|
||||
dealWithPagination(statusesTopCache, DIRECTION.TOP, false);
|
||||
} else {
|
||||
timelinesVM.getHome(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, false, null, null, min_id, MastodonHelper.statusesPerCall(requireActivity()), false)
|
||||
timelinesVM.getHome(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, BaseMainActivity.currentUserID, false, null, null, min_id, MastodonHelper.statusesPerCall(requireActivity()), false)
|
||||
.observe(getViewLifecycleOwner(), statusesTop -> dealWithPagination(statusesTop, DIRECTION.TOP, false));
|
||||
}
|
||||
});
|
||||
|
@ -962,12 +962,12 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
.observe(getViewLifecycleOwner(), statusesTop -> dealWithPagination(statusesTop, DIRECTION.TOP, false));
|
||||
}
|
||||
} else {
|
||||
timelinesVM.getHome(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, true, null, null, min_id_fetch_more, MastodonHelper.statusesPerCall(requireActivity()), false)
|
||||
timelinesVM.getHome(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, BaseMainActivity.currentUserID, true, null, null, min_id_fetch_more, MastodonHelper.statusesPerCall(requireActivity()), false)
|
||||
.observe(getViewLifecycleOwner(), statusesTop -> dealWithPagination(statusesTop, DIRECTION.TOP, true));
|
||||
}
|
||||
|
||||
} else if (direction == DIRECTION.REFRESH || direction == DIRECTION.SCROLL_TOP) {
|
||||
timelinesVM.getHome(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, true, null, null, null, MastodonHelper.statusesPerCall(requireActivity()), false)
|
||||
timelinesVM.getHome(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, BaseMainActivity.currentUserID, true, null, null, null, MastodonHelper.statusesPerCall(requireActivity()), false)
|
||||
.observe(getViewLifecycleOwner(), statusRefresh -> {
|
||||
if (statusAdapter != null) {
|
||||
dealWithPagination(statusRefresh, direction, true);
|
||||
|
|
|
@ -31,7 +31,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import app.fedilab.android.BaseMainActivity;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.client.endpoints.MastodonTimelinesService;
|
||||
import app.fedilab.android.client.entities.api.Account;
|
||||
|
@ -443,6 +442,7 @@ public class TimelinesVM extends AndroidViewModel {
|
|||
* @return {@link LiveData} containing a {@link Statuses}
|
||||
*/
|
||||
public LiveData<Statuses> getHome(@NonNull String instance, String token,
|
||||
String userId,
|
||||
boolean fetchingMissing,
|
||||
String maxId,
|
||||
String sinceId,
|
||||
|
@ -466,7 +466,7 @@ public class TimelinesVM extends AndroidViewModel {
|
|||
StatusCache statusCacheDAO = new StatusCache(getApplication().getApplicationContext());
|
||||
StatusCache statusCache = new StatusCache();
|
||||
statusCache.instance = instance;
|
||||
statusCache.user_id = BaseMainActivity.currentUserID;
|
||||
statusCache.user_id = userId;
|
||||
statusCache.status = status;
|
||||
statusCache.type = StatusCache.CacheEnum.HOME;
|
||||
statusCache.status_id = status.id;
|
||||
|
|
Loading…
Reference in a new issue