Add the pleroma object to the db

Remember emoji reactions and the 'reply to' text.
main
Karol Kosek 4 years ago
parent 34fa8b9664
commit 72a6b41bf6
  1. 12
      app/schemas/com.keylesspalace.tusky.db.AppDatabase/25.json
  2. 1
      app/src/main/java/com/keylesspalace/tusky/db/AppDatabase.java
  3. 2
      app/src/main/java/com/keylesspalace/tusky/db/TimelineDao.kt
  4. 3
      app/src/main/java/com/keylesspalace/tusky/db/TimelineStatusEntity.kt
  5. 16
      app/src/main/java/com/keylesspalace/tusky/repository/TimelineRepository.kt

@ -2,7 +2,7 @@
"formatVersion": 1, "formatVersion": 1,
"database": { "database": {
"version": 25, "version": 25,
"identityHash": "7ab8482b8d5dcb97c4c8932f578879f2", "identityHash": "fe234db47e8a1376fe941f10959fccca",
"entities": [ "entities": [
{ {
"tableName": "TootEntity", "tableName": "TootEntity",
@ -358,7 +358,7 @@
}, },
{ {
"tableName": "TimelineStatusEntity", "tableName": "TimelineStatusEntity",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`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, `visibility` INTEGER, `attachments` TEXT, `mentions` TEXT, `application` TEXT, `reblogServerId` TEXT, `reblogAccountId` TEXT, `poll` TEXT, PRIMARY KEY(`serverId`, `timelineUserId`), FOREIGN KEY(`authorServerId`, `timelineUserId`) REFERENCES `TimelineAccountEntity`(`serverId`, `timelineUserId`) ON UPDATE NO ACTION ON DELETE NO ACTION )", "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`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, `visibility` INTEGER, `attachments` TEXT, `mentions` TEXT, `application` TEXT, `reblogServerId` TEXT, `reblogAccountId` TEXT, `poll` TEXT, `pleroma` TEXT, PRIMARY KEY(`serverId`, `timelineUserId`), FOREIGN KEY(`authorServerId`, `timelineUserId`) REFERENCES `TimelineAccountEntity`(`serverId`, `timelineUserId`) ON UPDATE NO ACTION ON DELETE NO ACTION )",
"fields": [ "fields": [
{ {
"fieldPath": "serverId", "fieldPath": "serverId",
@ -497,6 +497,12 @@
"columnName": "poll", "columnName": "poll",
"affinity": "TEXT", "affinity": "TEXT",
"notNull": false "notNull": false
},
{
"fieldPath": "pleroma",
"columnName": "pleroma",
"affinity": "TEXT",
"notNull": false
} }
], ],
"primaryKey": { "primaryKey": {
@ -879,7 +885,7 @@
"views": [], "views": [],
"setupQueries": [ "setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '7ab8482b8d5dcb97c4c8932f578879f2')" "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'fe234db47e8a1376fe941f10959fccca')"
] ]
} }
} }

@ -372,6 +372,7 @@ public abstract class AppDatabase extends RoomDatabase {
"PRIMARY KEY (`localId`, `messageId`))"); "PRIMARY KEY (`localId`, `messageId`))");
database.execSQL("ALTER TABLE `InstanceEntity` ADD COLUMN `chatLimit` INTEGER"); database.execSQL("ALTER TABLE `InstanceEntity` ADD COLUMN `chatLimit` INTEGER");
database.execSQL("ALTER TABLE `AccountEntity` ADD COLUMN `notificationsChatMessages` INTEGER NOT NULL DEFAULT 1"); database.execSQL("ALTER TABLE `AccountEntity` ADD COLUMN `notificationsChatMessages` INTEGER NOT NULL DEFAULT 1");
database.execSQL("ALTER TABLE `TimelineStatusEntity` ADD COLUMN `pleroma` TEXT");
} }
}; };
} }

@ -26,7 +26,7 @@ SELECT s.serverId, s.url, s.timelineUserId,
s.authorServerId, s.inReplyToId, s.inReplyToAccountId, s.createdAt, s.authorServerId, s.inReplyToId, s.inReplyToAccountId, s.createdAt,
s.emojis, s.reblogsCount, s.favouritesCount, s.reblogged, s.favourited, s.bookmarked, s.sensitive, s.emojis, s.reblogsCount, s.favouritesCount, s.reblogged, s.favourited, s.bookmarked, s.sensitive,
s.spoilerText, s.visibility, s.mentions, s.application, s.reblogServerId,s.reblogAccountId, s.spoilerText, s.visibility, s.mentions, s.application, s.reblogServerId,s.reblogAccountId,
s.content, s.attachments, s.poll, s.content, s.attachments, s.poll, s.pleroma,
a.serverId as 'a_serverId', a.timelineUserId as 'a_timelineUserId', a.serverId as 'a_serverId', a.timelineUserId as 'a_timelineUserId',
a.localUsername as 'a_localUsername', a.username as 'a_username', a.localUsername as 'a_localUsername', a.username as 'a_username',
a.displayName as 'a_displayName', a.url as 'a_url', a.avatar as 'a_avatar', a.displayName as 'a_displayName', a.url as 'a_url', a.avatar as 'a_avatar',

@ -51,7 +51,8 @@ data class TimelineStatusEntity(
val application: String?, val application: String?,
val reblogServerId: String?, // if it has a reblogged status, it's id is stored here val reblogServerId: String?, // if it has a reblogged status, it's id is stored here
val reblogAccountId: String?, val reblogAccountId: String?,
val poll: String? val poll: String?,
val pleroma: String?
) )
@Entity( @Entity(

@ -208,6 +208,7 @@ class TimelineRepositoryImpl(
val emojis: List<Emoji> = gson.fromJson(status.emojis, val emojis: List<Emoji> = gson.fromJson(status.emojis,
object : TypeToken<List<Emoji>>() {}.type) ?: listOf() object : TypeToken<List<Emoji>>() {}.type) ?: listOf()
val poll: Poll? = gson.fromJson(status.poll, Poll::class.java) val poll: Poll? = gson.fromJson(status.poll, Poll::class.java)
val pleroma = gson.fromJson(status.pleroma, Status.PleromaStatus::class.java)
val reblog = status.reblogServerId?.let { id -> val reblog = status.reblogServerId?.let { id ->
Status( Status(
@ -233,7 +234,8 @@ class TimelineRepositoryImpl(
application = application, application = application,
pinned = false, pinned = false,
poll = poll, poll = poll,
card = null card = null,
pleroma = pleroma
) )
} }
val status = if (reblog != null) { val status = if (reblog != null) {
@ -260,7 +262,8 @@ class TimelineRepositoryImpl(
application = null, application = null,
pinned = false, pinned = false,
poll = null, poll = null,
card = null card = null,
pleroma = null
) )
} else { } else {
Status( Status(
@ -286,7 +289,8 @@ class TimelineRepositoryImpl(
application = application, application = application,
pinned = false, pinned = false,
poll = poll, poll = poll,
card = null card = null,
pleroma = pleroma
) )
} }
return Either.Right(status) return Either.Right(status)
@ -356,7 +360,8 @@ fun Placeholder.toEntity(timelineUserId: Long): TimelineStatusEntity {
application = null, application = null,
reblogServerId = null, reblogServerId = null,
reblogAccountId = null, reblogAccountId = null,
poll = null poll = null,
pleroma = null
) )
} }
@ -386,7 +391,8 @@ fun Status.toEntity(timelineUserId: Long,
application = actionable.application.let(gson::toJson), application = actionable.application.let(gson::toJson),
reblogServerId = reblog?.id, reblogServerId = reblog?.id,
reblogAccountId = reblog?.let { this.account.id }, reblogAccountId = reblog?.let { this.account.id },
poll = actionable.poll.let(gson::toJson) poll = actionable.poll.let(gson::toJson),
pleroma = actionable.pleroma.let(gson::toJson)
) )
} }

Loading…
Cancel
Save