Records home logs

inspect_home_cache
Thomas 2 years ago
parent 84814d3291
commit f616b7df0e

@ -112,11 +112,14 @@ public class Status implements Serializable, Cloneable {
@SerializedName("reactions") @SerializedName("reactions")
public List<Reaction> reactions; public List<Reaction> reactions;
public boolean isFetchMore = false;
public PositionFetchMore positionFetchMore = PositionFetchMore.BOTTOM;
public Attachment art_attachment; public Attachment art_attachment;
public boolean isExpended = false; public boolean isExpended = false;
public boolean isTruncated = true; public boolean isTruncated = true;
public transient boolean isFetchMore = false;
public transient PositionFetchMore positionFetchMore = PositionFetchMore.BOTTOM;
public boolean isChecked = false; public boolean isChecked = false;
//When forwarding tags //When forwarding tags
public boolean tagAdded = false; public boolean tagAdded = false;

@ -173,6 +173,8 @@ public class FetchHomeWorker extends Worker {
if (fetch_home) { if (fetch_home) {
int max_calls = 10; int max_calls = 10;
int status_per_page = 40; int status_per_page = 40;
int insertValue = 0;
StatusCache lastStatusCache = null;
//Browse last 400 home messages //Browse last 400 home messages
boolean canContinue = true; boolean canContinue = true;
int call = 0; int call = 0;
@ -194,9 +196,10 @@ public class FetchHomeWorker extends Worker {
statusCache.status = status; statusCache.status = status;
statusCache.type = Timeline.TimeLineEnum.HOME; statusCache.type = Timeline.TimeLineEnum.HOME;
statusCache.status_id = status.id; statusCache.status_id = status.id;
lastStatusCache = statusCache;
try { try {
int insertOrUpdate = statusCacheDAO.insertOrUpdate(statusCache, Timeline.TimeLineEnum.HOME.getValue()); insertValue = statusCacheDAO.insertOrUpdate(statusCache, Timeline.TimeLineEnum.HOME.getValue());
if (insertOrUpdate == 1) { if (insertValue == 1) {
inserted++; inserted++;
} else { } else {
updated++; updated++;
@ -246,7 +249,17 @@ public class FetchHomeWorker extends Worker {
} catch (DBException e) { } catch (DBException e) {
throw new RuntimeException(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);
}
}
} }
} }

@ -109,7 +109,7 @@ public class TimelinesVM extends AndroidViewModel {
} }
private static void addFetchMore(List<Status> statusList, List<Status> timelineStatuses, TimelineParams timelineParams) throws DBException { 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); sortDesc(statusList);
if (timelineParams.direction == FragmentMastodonTimeline.DIRECTION.REFRESH || timelineParams.direction == FragmentMastodonTimeline.DIRECTION.SCROLL_TOP || timelineParams.direction == FragmentMastodonTimeline.DIRECTION.FETCH_NEW) { 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 //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 { 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); sortDescConv(conversationList);
if (timelineParams.direction == FragmentMastodonTimeline.DIRECTION.REFRESH || timelineParams.direction == FragmentMastodonTimeline.DIRECTION.SCROLL_TOP || timelineParams.direction == FragmentMastodonTimeline.DIRECTION.FETCH_NEW) { 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 //When refreshing/scrolling to TOP, if last statuses fetched has a greater id from newest in cache, there is potential hole

Loading…
Cancel
Save