Timeline paging (#2238)

* first setup

* network timeline paging / improvements

* rename classes / move to correct package

* remove unused class TimelineAdapter

* some code cleanup

* remove TimelineRepository, put mapper functions in TimelineTypeMappers.kt

* add db migration

* cleanup unused code

* bugfix

* make default timeline settings work again

* fix pinning statuses from timeline

* fix network timeline

* respect account settings in NetworkTimelineRemoteMediator

* respect account settings in NetworkTimelineRemoteMediator

* update license headers

* show error view when an error occurs

* cleanup some todos

* fix db migration

* fix changing mediaPreviewEnabled setting

* fix "load more" button appearing on top of timeline

* fix filtering and other bugs

* cleanup cache after 14 days

* fix TimelineDAOTest

* fix code formatting

* add NetworkTimeline unit tests

* add CachedTimeline unit tests

* fix code formatting

* move TimelineDaoTest to unit tests

* implement removeAllByInstance for CachedTimelineViewModel

* fix code formatting

* fix bug in TimelineDao.deleteAllFromInstance

* improve loading more statuses in NetworkTimelineViewModel

* improve loading more statuses in NetworkTimelineViewModel

* fix bug where empty state was shown too soon

* reload top of cached timeline on app start

* improve CachedTimelineRemoteMediator and Tests

* improve cached timeline tests

* fix some more todos

* implement TimelineFragment.removeItem

* fix ListStatusAccessibilityDelegate

* fix crash in NetworkTimelineViewModel.loadMore

* fix default state of collapsible statuses

* fix default state of collapsible statuses -tests

* fix showing/hiding media in the timeline

* get rid of some not-null assertion operators in TimelineTypeMappers

* fix tests

* error handling in CachedTimelineViewModel.loadMore

* keep local status state when refreshing cached statuses

* keep local status state when refreshing network timeline statuses

* show placeholder loading state in cached timeline

* better comments, some code cleanup

* add TimelineViewModelTest, improve code, fix bug

* fix ktlint

* fix voting in boosted polls

* code improvement
This commit is contained in:
Konrad Pozniak 2022-01-11 19:00:29 +01:00 committed by GitHub
commit 643e012b11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
41 changed files with 4019 additions and 3146 deletions

View file

@ -32,7 +32,7 @@ import java.io.File;
@Database(entities = { DraftEntity.class, AccountEntity.class, InstanceEntity.class, TimelineStatusEntity.class,
TimelineAccountEntity.class, ConversationEntity.class
}, version = 27)
}, version = 28)
public abstract class AppDatabase extends RoomDatabase {
public abstract AccountDao accountDao();
@ -400,4 +400,61 @@ public abstract class AppDatabase extends RoomDatabase {
database.execSQL("ALTER TABLE `ConversationEntity` ADD COLUMN `s_muted` INTEGER NOT NULL DEFAULT 0");
}
};
public static final Migration MIGRATION_27_28 = new Migration(27, 28) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
database.execSQL("DROP TABLE IF EXISTS `TimelineAccountEntity`");
database.execSQL("DROP TABLE IF EXISTS `TimelineStatusEntity`");
database.execSQL("CREATE TABLE IF NOT EXISTS `TimelineAccountEntity` (" +
"`serverId` TEXT NOT NULL," +
"`timelineUserId` INTEGER 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," +
"`bot` INTEGER 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," +
"`inReplyToId` TEXT," +
"`inReplyToAccountId` TEXT," +
"`content` TEXT," +
"`createdAt` INTEGER NOT NULL," +
"`emojis` TEXT," +
"`reblogsCount` INTEGER NOT NULL," +
"`favouritesCount` INTEGER NOT NULL," +
"`reblogged` INTEGER NOT NULL," +
"`bookmarked` INTEGER NOT NULL," +
"`favourited` INTEGER NOT NULL," +
"`sensitive` INTEGER NOT NULL," +
"`spoilerText` TEXT NOT NULL," +
"`visibility` INTEGER NOT NULL," +
"`attachments` TEXT," +
"`mentions` TEXT," +
"`application` TEXT," +
"`reblogServerId` TEXT," +
"`reblogAccountId` TEXT," +
"`poll` TEXT," +
"`muted` INTEGER," +
"`expanded` INTEGER NOT NULL," +
"`contentCollapsed` INTEGER NOT NULL," +
"`contentShowing` INTEGER NOT NULL," +
"`pinned` INTEGER NOT NULL," +
"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`)");
}
};
}