summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas <tschneider.ac@gmail.com>2023-03-07 12:05:27 +0100
committerThomas <tschneider.ac@gmail.com>2023-03-07 12:05:27 +0100
commitf616b7df0e6359b748d04c15f6267ce1bc2361a2 (patch)
tree433d281278a7f6a161c0a73e4b24a99aa857bf46
parent84814d329156e56cc306d64705517e67ab5efc19 (diff)
Records home logsinspect_home_cache
-rw-r--r--app/src/main/java/app/fedilab/android/mastodon/client/entities/api/Status.java7
-rw-r--r--app/src/main/java/app/fedilab/android/mastodon/jobs/FetchHomeWorker.java19
-rw-r--r--app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/TimelinesVM.java4
3 files changed, 23 insertions, 7 deletions
diff --git a/app/src/main/java/app/fedilab/android/mastodon/client/entities/api/Status.java b/app/src/main/java/app/fedilab/android/mastodon/client/entities/api/Status.java
index 2d373a74b..341c2a952 100644
--- a/app/src/main/java/app/fedilab/android/mastodon/client/entities/api/Status.java
+++ b/app/src/main/java/app/fedilab/android/mastodon/client/entities/api/Status.java
@@ -112,11 +112,14 @@ public class Status implements Serializable, Cloneable {
@SerializedName("reactions")
public List<Reaction> reactions;
+
+ public boolean isFetchMore = false;
+ public PositionFetchMore positionFetchMore = PositionFetchMore.BOTTOM;
+
public Attachment art_attachment;
public boolean isExpended = false;
public boolean isTruncated = true;
- public transient boolean isFetchMore = false;
- public transient PositionFetchMore positionFetchMore = PositionFetchMore.BOTTOM;
+
public boolean isChecked = false;
//When forwarding tags
public boolean tagAdded = false;
diff --git a/app/src/main/java/app/fedilab/android/mastodon/jobs/FetchHomeWorker.java b/app/src/main/java/app/fedilab/android/mastodon/jobs/FetchHomeWorker.java
index f240c26fd..0227b7ae8 100644
--- a/app/src/main/java/app/fedilab/android/mastodon/jobs/FetchHomeWorker.java
+++ b/app/src/main/java/app/fedilab/android/mastodon/jobs/FetchHomeWorker.java
@@ -173,6 +173,8 @@ public class FetchHomeWorker extends Worker {
if (fetch_home) {
int max_calls = 10;
int status_per_page = 40;
+ int insertValue = 0;
+ StatusCache lastStatusCache = null;
//Browse last 400 home messages
boolean canContinue = true;
int call = 0;
@@ -194,9 +196,10 @@ public class FetchHomeWorker extends Worker {
statusCache.status = status;
statusCache.type = Timeline.TimeLineEnum.HOME;
statusCache.status_id = status.id;
+ lastStatusCache = statusCache;
try {
- int insertOrUpdate = statusCacheDAO.insertOrUpdate(statusCache, Timeline.TimeLineEnum.HOME.getValue());
- if (insertOrUpdate == 1) {
+ insertValue = statusCacheDAO.insertOrUpdate(statusCache, Timeline.TimeLineEnum.HOME.getValue());
+ if (insertValue == 1) {
inserted++;
} else {
updated++;
@@ -246,7 +249,17 @@ public class FetchHomeWorker extends Worker {
} catch (DBException e) {
throw new RuntimeException(e);
}
-
+ //insertValue is for last status and equals zero if updated or 1 if inserted
+ if (lastStatusCache != null && insertValue == 1) { //Last inserted message was not in cache.
+ StatusCache statusCacheDAO = new StatusCache(getApplicationContext());
+ lastStatusCache.status.isFetchMore = true;
+ lastStatusCache.status.positionFetchMore = Status.PositionFetchMore.TOP;
+ try {
+ statusCacheDAO.updateIfExists(lastStatusCache);
+ } catch (DBException e) {
+ throw new RuntimeException(e);
+ }
+ }
}
}
diff --git a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/TimelinesVM.java b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/TimelinesVM.java
index 5eb542ba0..55800510c 100644
--- a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/TimelinesVM.java
+++ b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/TimelinesVM.java
@@ -109,7 +109,7 @@ public class TimelinesVM extends AndroidViewModel {
}
private static void addFetchMore(List<Status> statusList, List<Status> timelineStatuses, TimelineParams timelineParams) throws DBException {
- if (statusList != null && statusList.size() > 0 && timelineStatuses != null && timelineStatuses.size() > 0) {
+ if (statusList != null && statusList.size() > 1 && timelineStatuses != null && timelineStatuses.size() > 0) {
sortDesc(statusList);
if (timelineParams.direction == FragmentMastodonTimeline.DIRECTION.REFRESH || timelineParams.direction == FragmentMastodonTimeline.DIRECTION.SCROLL_TOP || timelineParams.direction == FragmentMastodonTimeline.DIRECTION.FETCH_NEW) {
//When refreshing/scrolling to TOP, if last statuses fetched has a greater id from newest in cache, there is potential hole
@@ -132,7 +132,7 @@ public class TimelinesVM extends AndroidViewModel {
}
private static void addFetchMoreConversation(List<Conversation> conversationList, List<Conversation> timelineConversations, TimelineParams timelineParams) throws DBException {
- if (conversationList != null && conversationList.size() > 0 && timelineConversations != null && timelineConversations.size() > 0) {
+ if (conversationList != null && conversationList.size() > 1 && timelineConversations != null && timelineConversations.size() > 0) {
sortDescConv(conversationList);
if (timelineParams.direction == FragmentMastodonTimeline.DIRECTION.REFRESH || timelineParams.direction == FragmentMastodonTimeline.DIRECTION.SCROLL_TOP || timelineParams.direction == FragmentMastodonTimeline.DIRECTION.FETCH_NEW) {
//When refreshing/scrolling to TOP, if last statuses fetched has a greater id from newest in cache, there is potential hole