Skip to content

Commit

Permalink
refactor: Rename TimelineStatusEntity to StatusEntity (#1251)
Browse files Browse the repository at this point in the history
TimelineStatusEntity is going to be repurposed for the table that maps
between a timeline (not just the home timeline) and the statuses on that
timeline.
  • Loading branch information
nikclayton authored Feb 1, 2025
1 parent 66b94e6 commit d42eba9
Show file tree
Hide file tree
Showing 11 changed files with 2,035 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import app.pachli.core.database.dao.TimelineDao
import app.pachli.core.database.di.TransactionProvider
import app.pachli.core.database.model.RemoteKeyEntity
import app.pachli.core.database.model.RemoteKeyEntity.RemoteKeyKind
import app.pachli.core.database.model.StatusEntity
import app.pachli.core.database.model.TimelineAccountEntity
import app.pachli.core.database.model.TimelineStatusEntity
import app.pachli.core.database.model.TimelineStatusWithAccount
import app.pachli.core.network.model.Links
import app.pachli.core.network.model.Status
Expand Down Expand Up @@ -259,7 +259,7 @@ class CachedTimelineRemoteMediator(
}

timelineDao.upsertAccounts(accounts.map { TimelineAccountEntity.from(it, pachliAccountId) })
timelineDao.upsertStatuses(statuses.map { TimelineStatusEntity.from(it, pachliAccountId) })
timelineDao.upsertStatuses(statuses.map { StatusEntity.from(it, pachliAccountId) })
}

companion object {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/app/pachli/network/ContentFilterModel.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package app.pachli.network

import app.pachli.core.data.model.from
import app.pachli.core.database.model.TimelineStatusEntity
import app.pachli.core.database.model.StatusEntity
import app.pachli.core.model.ContentFilter
import app.pachli.core.model.FilterAction
import app.pachli.core.model.FilterContext
Expand Down Expand Up @@ -63,7 +63,7 @@ class ContentFilterModel(private val filterContext: FilterContext, v1ContentFilt
}

/** @return the [FilterAction] that should be applied to this status */
fun filterActionFor(status: TimelineStatusEntity): FilterAction {
fun filterActionFor(status: StatusEntity): FilterAction {
pattern?.let { pat ->
// Patterns are expensive and thread-safe, matchers are neither.
val matcher = pat.matcher("") ?: return FilterAction.NONE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package app.pachli.components.timeline

import app.pachli.core.data.model.StatusViewData
import app.pachli.core.database.model.StatusEntity
import app.pachli.core.database.model.StatusViewDataEntity
import app.pachli.core.database.model.TimelineAccountEntity
import app.pachli.core.database.model.TimelineStatusEntity
import app.pachli.core.database.model.TimelineStatusWithAccount
import app.pachli.core.database.model.TranslationState
import app.pachli.core.network.model.Status
Expand Down Expand Up @@ -99,7 +99,7 @@ fun mockStatusEntityWithAccount(
val mockedStatus = mockStatus(id)

return TimelineStatusWithAccount(
status = TimelineStatusEntity.from(
status = StatusEntity.from(
mockedStatus,
timelineUserId = userId,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import app.pachli.core.database.model.NotificationRelationshipSeveranceEventEnti
import app.pachli.core.database.model.NotificationReportEntity
import app.pachli.core.database.model.RemoteKeyEntity
import app.pachli.core.database.model.RemoteKeyEntity.RemoteKeyKind
import app.pachli.core.database.model.StatusEntity
import app.pachli.core.database.model.TimelineAccountEntity
import app.pachli.core.database.model.TimelineStatusEntity
import app.pachli.core.database.model.TimelineStatusWithAccount
import app.pachli.core.network.model.Links
import app.pachli.core.network.model.Notification
Expand Down Expand Up @@ -282,7 +282,7 @@ class NotificationsRemoteMediator(

// Bulk upsert the discovered items.
timelineDao.upsertAccounts(accounts.map { TimelineAccountEntity.from(it, pachliAccountId) })
timelineDao.upsertStatuses(statuses.map { TimelineStatusEntity.from(it, pachliAccountId) })
timelineDao.upsertStatuses(statuses.map { StatusEntity.from(it, pachliAccountId) })
notificationDao.upsertReports(reports.mapNotNull { NotificationReportEntity.from(pachliAccountId, it) })
notificationDao.upsertEvents(
severanceEvents.mapNotNull {
Expand All @@ -303,7 +303,7 @@ fun NotificationData.Companion.from(pachliAccountId: Long, notification: Notific
account = TimelineAccountEntity.from(notification.account, pachliAccountId),
status = notification.status?.let { status ->
TimelineStatusWithAccount(
status = TimelineStatusEntity.from(status, pachliAccountId),
status = StatusEntity.from(status, pachliAccountId),
account = TimelineAccountEntity.from(status.account, pachliAccountId),
)
},
Expand Down
Loading

0 comments on commit d42eba9

Please sign in to comment.