Commit 6346c9cb authored by Thomas's avatar Thomas
Browse files

Fix empty home timeline

parent 5a02bbf2
Pipeline #310160 passed with stage
in 4 minutes and 9 seconds
......@@ -1062,7 +1062,6 @@ public class DisplayStatusFragment extends Fragment implements OnPostActionInter
@Override
public void onRetrieveFeedsAfterBookmark(APIResponse apiResponse) {
if (statusListAdapter == null && pixelfedListAdapter == null)
return;
if (apiResponse == null || (apiResponse.getError() != null && apiResponse.getError().getStatusCode() != 404 && apiResponse.getError().getStatusCode() != 501)) {
......@@ -1078,36 +1077,42 @@ public class DisplayStatusFragment extends Fragment implements OnPostActionInter
return;
}
List<Status> statuses = apiResponse.getStatuses();
if (statuses == null || statuses.size() == 0 || this.statuses == null)
return;
//Find the position of toots between those already present
int position = 0;
if (position < this.statuses.size() && statuses.get(0).getCreated_at() != null && this.statuses.get(position).getCreated_at() != null) {
while (position < this.statuses.size() && statuses.get(0).getCreated_at().before(this.statuses.get(position).getCreated_at())) {
position++;
}
}
ArrayList<Status> tmpStatuses = new ArrayList<>();
for (Status tmpStatus : statuses) {
//Put the toot at its place in the list (id desc)
if (!apiResponse.isFetchmore() && this.statuses.size() > 0 && !this.statuses.contains(tmpStatus) && tmpStatus.getCreated_at() != null && this.statuses.get(0).getCreated_at() != null && tmpStatus.getCreated_at().after(this.statuses.get(0).getCreated_at())) { //Element not already added
//Mark status at new ones when their id is greater than the last read toot id
if ((type == RetrieveFeedsAsyncTask.Type.HOME || type == RetrieveFeedsAsyncTask.Type.PF_HOME) && lastReadTootDate != null && tmpStatus.getCreated_at().after(lastReadTootDate)) {
tmpStatus.setNew(true);
MainActivity.countNewStatus++;
}
tmpStatuses.add(tmpStatus);
} else if (apiResponse.isFetchmore() && !this.statuses.contains(tmpStatus)) { //Element not already added
//Mark status at new ones when their id is greater than the last read toot id
if ((type == RetrieveFeedsAsyncTask.Type.HOME || type == RetrieveFeedsAsyncTask.Type.PF_HOME) && lastReadTootDate != null && tmpStatus.getCreated_at().after(lastReadTootDate)) {
tmpStatus.setNew(true);
MainActivity.countNewStatus++;
if (this.statuses.size() > 0) {
for (Status tmpStatus : statuses) {
//Put the toot at its place in the list (id desc)
if (!apiResponse.isFetchmore() && this.statuses.size() > 0 && !this.statuses.contains(tmpStatus) && tmpStatus.getCreated_at() != null && this.statuses.get(0).getCreated_at() != null && tmpStatus.getCreated_at().after(this.statuses.get(0).getCreated_at())) { //Element not already added
//Mark status at new ones when their id is greater than the last read toot id
if ((type == RetrieveFeedsAsyncTask.Type.HOME || type == RetrieveFeedsAsyncTask.Type.PF_HOME) && lastReadTootDate != null && tmpStatus.getCreated_at().after(lastReadTootDate)) {
tmpStatus.setNew(true);
MainActivity.countNewStatus++;
}
tmpStatuses.add(tmpStatus);
} else if (apiResponse.isFetchmore() && !this.statuses.contains(tmpStatus)) { //Element not already added
//Mark status at new ones when their id is greater than the last read toot id
if ((type == RetrieveFeedsAsyncTask.Type.HOME || type == RetrieveFeedsAsyncTask.Type.PF_HOME) && lastReadTootDate != null && tmpStatus.getCreated_at().after(lastReadTootDate)) {
tmpStatus.setNew(true);
MainActivity.countNewStatus++;
}
tmpStatuses.add(tmpStatus);
}
tmpStatuses.add(tmpStatus);
}
} else {
this.statuses.addAll(statuses);
tmpStatuses.addAll(statuses);
}
try {
((MainActivity) context).updateHomeCounter();
} catch (Exception ignored) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment