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
|
|
@ -25,12 +25,15 @@ import androidx.annotation.NonNull;
|
|||
* DB version & declare DAO
|
||||
*/
|
||||
|
||||
@Database(entities = {TootEntity.class, AccountEntity.class, InstanceEntity.class}, version = 10)
|
||||
@Database(entities = {TootEntity.class, AccountEntity.class, InstanceEntity.class,TimelineStatusEntity.class,
|
||||
TimelineAccountEntity.class
|
||||
}, version = 11)
|
||||
public abstract class AppDatabase extends RoomDatabase {
|
||||
|
||||
public abstract TootDao tootDao();
|
||||
public abstract AccountDao accountDao();
|
||||
public abstract InstanceDao instanceDao();
|
||||
public abstract TimelineDao timelineDao();
|
||||
|
||||
public static final Migration MIGRATION_2_3 = new Migration(2, 3) {
|
||||
@Override
|
||||
|
|
@ -116,4 +119,51 @@ public abstract class AppDatabase extends RoomDatabase {
|
|||
}
|
||||
};
|
||||
|
||||
public static final Migration MIGRATION_10_11 = new Migration(10, 11) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||
database.execSQL("CREATE TABLE IF NOT EXISTS `TimelineAccountEntity` (" +
|
||||
"`serverId` TEXT NOT NULL, " +
|
||||
"`timelineUserId` INTEGER NOT NULL, " +
|
||||
"`instance` TEXT NOT NULL, " +
|
||||
"`localUsername` TEXT NOT NULL, " +
|
||||
"`username` TEXT NOT NULL, " +
|
||||
"`displayName` TEXT NOT NULL, " +
|
||||
"`url` TEXT NOT NULL, " +
|
||||
"`avatar` TEXT NOT NULL, " +
|
||||
"`emojis` TEXT NOT NULL," +
|
||||
"PRIMARY KEY(`serverId`, `timelineUserId`))");
|
||||
|
||||
database.execSQL("CREATE TABLE IF NOT EXISTS `TimelineStatusEntity` (" +
|
||||
"`serverId` TEXT NOT NULL, " +
|
||||
"`url` TEXT, " +
|
||||
"`timelineUserId` INTEGER NOT NULL, " +
|
||||
"`authorServerId` TEXT," +
|
||||
"`instance` TEXT, " +
|
||||
"`inReplyToId` TEXT, " +
|
||||
"`inReplyToAccountId` TEXT, " +
|
||||
"`content` TEXT, " +
|
||||
"`createdAt` INTEGER NOT NULL, " +
|
||||
"`emojis` TEXT, " +
|
||||
"`reblogsCount` INTEGER NOT NULL, " +
|
||||
"`favouritesCount` INTEGER NOT NULL, " +
|
||||
"`reblogged` INTEGER NOT NULL, " +
|
||||
"`favourited` INTEGER NOT NULL, " +
|
||||
"`sensitive` INTEGER NOT NULL, " +
|
||||
"`spoilerText` TEXT, " +
|
||||
"`visibility` INTEGER, " +
|
||||
"`attachments` TEXT, " +
|
||||
"`mentions` TEXT, " +
|
||||
"`application` TEXT, " +
|
||||
"`reblogServerId` TEXT, " +
|
||||
"`reblogAccountId` TEXT," +
|
||||
" PRIMARY KEY(`serverId`, `timelineUserId`)," +
|
||||
" FOREIGN KEY(`authorServerId`, `timelineUserId`) REFERENCES `TimelineAccountEntity`(`serverId`, `timelineUserId`) " +
|
||||
"ON UPDATE NO ACTION ON DELETE NO ACTION )");
|
||||
database.execSQL("CREATE INDEX IF NOT EXISTS" +
|
||||
"`index_TimelineStatusEntity_authorServerId_timelineUserId` " +
|
||||
"ON `TimelineStatusEntity` (`authorServerId`, `timelineUserId`)");
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue