Caching toots (#809)
* Initial timeline cache implementation * Fix build/DI errors for caching * Rename timeline entities tables. Add migration. Add DB scheme file. * Fix uniqueness problem, change offline strategy, improve mapping * Try to merge in new statuses, fix bottom loading, fix saving spans. * Fix reblogs IDs, fix inserting elements from top * Send one more request to get latest timeline statuses * Give Timeline placeholders string id. Rewrite Either in Kotlin * Initial placeholder implementation for caching * Fix crash on removing overlap statuses * Migrate counters to long * Remove unused counters. Add minimal TimelineDAOTest * Fix bug with placeholder ID * Update cache in response to events. Refactor TimelineCases * Fix crash, reduce number of placeholders * Fix crash, fix filtering, improve placeholder handling * Fix migration, add 8-9 migration test * Fix initial timeline update, remove more placeholders * Add cleanup for old statuses * Fix cleanup * Delete ExampleInstrumentedTest * Improve timeline UX regarding caching * Fix typos * Fix initial timeline update * Cleanup/fix initial timeline update * Workaround for weird behavior of first post on initial tl update. * Change counter types back to int * Clear timeline cache on logout * Fix loading when timeline is completely empty * Fix androidx migration issues * Fix tests * Apply caching feedback * Save account emojis to cache * Fix warnings and bugs
This commit is contained in:
parent
75158a3aa0
commit
3ab78a19bc
29 changed files with 1950 additions and 497 deletions
|
|
@ -236,43 +236,35 @@ public final class ViewThreadFragment extends SFragment implements
|
|||
@Override
|
||||
public void onReblog(final boolean reblog, final int position) {
|
||||
final Status status = statuses.get(position);
|
||||
timelineCases.reblogWithCallback(statuses.get(position), reblog, new Callback<Status>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Status> call, @NonNull Response<Status> response) {
|
||||
if (response.isSuccessful()) {
|
||||
updateStatus(position, response.body());
|
||||
|
||||
eventHub.dispatch(new ReblogEvent(status.getId(), reblog));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Status> call, @NonNull Throwable t) {
|
||||
Log.d(getClass().getSimpleName(), "Failed to reblog status: " + status.getId());
|
||||
t.printStackTrace();
|
||||
}
|
||||
});
|
||||
timelineCases.reblog(statuses.get(position), reblog)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.as(autoDisposable(from(this)))
|
||||
.subscribe(
|
||||
(newStatus) -> updateStatus(position, newStatus),
|
||||
(t) -> {
|
||||
Log.d(getClass().getSimpleName(),
|
||||
"Failed to reblog status: " + status.getId());
|
||||
t.printStackTrace();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFavourite(final boolean favourite, final int position) {
|
||||
final Status status = statuses.get(position);
|
||||
timelineCases.favouriteWithCallback(statuses.get(position), favourite, new Callback<Status>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Status> call, @NonNull Response<Status> response) {
|
||||
if (response.isSuccessful()) {
|
||||
updateStatus(position, response.body());
|
||||
|
||||
eventHub.dispatch(new FavoriteEvent(status.getId(), favourite));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Status> call, @NonNull Throwable t) {
|
||||
Log.d(getClass().getSimpleName(), "Failed to favourite status: " + status.getId());
|
||||
t.printStackTrace();
|
||||
}
|
||||
});
|
||||
timelineCases.favourite(statuses.get(position), favourite)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.as(autoDisposable(from(this)))
|
||||
.subscribe(
|
||||
(newStatus) -> updateStatus(position, newStatus),
|
||||
(t) -> {
|
||||
Log.d(getClass().getSimpleName(), "Failed to favourite status: " + status.getId());
|
||||
t.printStackTrace();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private void updateStatus(int position, Status status) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue