2022-01-11 19:00:29 +01:00
|
|
|
package com.keylesspalace.tusky.components.timeline
|
|
|
|
|
|
|
|
import com.google.gson.Gson
|
|
|
|
import com.keylesspalace.tusky.db.TimelineStatusWithAccount
|
|
|
|
import com.keylesspalace.tusky.entity.Status
|
2022-03-15 21:34:57 +01:00
|
|
|
import com.keylesspalace.tusky.entity.TimelineAccount
|
2022-01-11 19:00:29 +01:00
|
|
|
import com.keylesspalace.tusky.viewdata.StatusViewData
|
|
|
|
import java.util.Date
|
|
|
|
|
|
|
|
private val fixedDate = Date(1638889052000)
|
|
|
|
|
2022-08-15 11:00:18 +02:00
|
|
|
fun mockStatus(
|
|
|
|
id: String = "100",
|
|
|
|
inReplyToId: String? = null,
|
|
|
|
inReplyToAccountId: String? = null,
|
|
|
|
spoilerText: String = "",
|
|
|
|
reblogged: Boolean = false,
|
|
|
|
favourited: Boolean = true,
|
|
|
|
bookmarked: Boolean = true
|
|
|
|
) = Status(
|
2022-01-11 19:00:29 +01:00
|
|
|
id = id,
|
|
|
|
url = "https://mastodon.example/@ConnyDuck/$id",
|
2022-03-15 21:34:57 +01:00
|
|
|
account = TimelineAccount(
|
2022-01-11 19:00:29 +01:00
|
|
|
id = "1",
|
|
|
|
localUsername = "connyduck",
|
|
|
|
username = "connyduck@mastodon.example",
|
|
|
|
displayName = "Conny Duck",
|
2023-04-24 12:09:34 +02:00
|
|
|
note = "This is their bio",
|
2022-01-11 19:00:29 +01:00
|
|
|
url = "https://mastodon.example/@ConnyDuck",
|
2022-03-15 21:34:57 +01:00
|
|
|
avatar = "https://mastodon.example/system/accounts/avatars/000/150/486/original/ab27d7ddd18a10ea.jpg"
|
2022-01-11 19:00:29 +01:00
|
|
|
),
|
2022-08-15 11:00:18 +02:00
|
|
|
inReplyToId = inReplyToId,
|
|
|
|
inReplyToAccountId = inReplyToAccountId,
|
2022-01-11 19:00:29 +01:00
|
|
|
reblog = null,
|
2022-04-15 13:20:27 +02:00
|
|
|
content = "Test",
|
2022-01-11 19:00:29 +01:00
|
|
|
createdAt = fixedDate,
|
2022-12-03 12:15:54 +01:00
|
|
|
editedAt = null,
|
2022-01-11 19:00:29 +01:00
|
|
|
emojis = emptyList(),
|
|
|
|
reblogsCount = 1,
|
|
|
|
favouritesCount = 2,
|
2022-05-20 16:47:45 +02:00
|
|
|
repliesCount = 3,
|
2022-08-15 11:00:18 +02:00
|
|
|
reblogged = reblogged,
|
|
|
|
favourited = favourited,
|
|
|
|
bookmarked = bookmarked,
|
2022-01-11 19:00:29 +01:00
|
|
|
sensitive = true,
|
2022-08-15 11:00:18 +02:00
|
|
|
spoilerText = spoilerText,
|
2022-01-11 19:00:29 +01:00
|
|
|
visibility = Status.Visibility.PUBLIC,
|
|
|
|
attachments = ArrayList(),
|
|
|
|
mentions = emptyList(),
|
2022-02-25 18:56:21 +01:00
|
|
|
tags = emptyList(),
|
2022-01-11 19:00:29 +01:00
|
|
|
application = Status.Application("Tusky", "https://tusky.app"),
|
|
|
|
pinned = false,
|
|
|
|
muted = false,
|
|
|
|
poll = null,
|
2022-08-31 18:53:57 +02:00
|
|
|
card = null,
|
|
|
|
language = null,
|
2023-03-13 13:16:39 +01:00
|
|
|
filtered = null
|
2022-01-11 19:00:29 +01:00
|
|
|
)
|
|
|
|
|
2022-08-15 11:00:18 +02:00
|
|
|
fun mockStatusViewData(
|
|
|
|
id: String = "100",
|
|
|
|
inReplyToId: String? = null,
|
|
|
|
inReplyToAccountId: String? = null,
|
|
|
|
isDetailed: Boolean = false,
|
|
|
|
spoilerText: String = "",
|
|
|
|
isExpanded: Boolean = false,
|
|
|
|
isShowingContent: Boolean = false,
|
|
|
|
isCollapsed: Boolean = !isDetailed,
|
|
|
|
reblogged: Boolean = false,
|
|
|
|
favourited: Boolean = true,
|
|
|
|
bookmarked: Boolean = true
|
|
|
|
) = StatusViewData.Concrete(
|
|
|
|
status = mockStatus(
|
|
|
|
id = id,
|
|
|
|
inReplyToId = inReplyToId,
|
|
|
|
inReplyToAccountId = inReplyToAccountId,
|
|
|
|
spoilerText = spoilerText,
|
|
|
|
reblogged = reblogged,
|
|
|
|
favourited = favourited,
|
|
|
|
bookmarked = bookmarked
|
|
|
|
),
|
|
|
|
isExpanded = isExpanded,
|
|
|
|
isShowingContent = isShowingContent,
|
|
|
|
isCollapsed = isCollapsed,
|
|
|
|
isDetailed = isDetailed
|
2022-01-11 19:00:29 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
fun mockStatusEntityWithAccount(
|
|
|
|
id: String = "100",
|
|
|
|
userId: Long = 1,
|
|
|
|
expanded: Boolean = false
|
|
|
|
): TimelineStatusWithAccount {
|
|
|
|
val mockedStatus = mockStatus(id)
|
|
|
|
val gson = Gson()
|
|
|
|
|
2023-02-04 20:22:29 +01:00
|
|
|
return TimelineStatusWithAccount(
|
2022-01-11 19:00:29 +01:00
|
|
|
status = mockedStatus.toEntity(
|
|
|
|
timelineUserId = userId,
|
|
|
|
gson = gson,
|
|
|
|
expanded = expanded,
|
|
|
|
contentShowing = false,
|
|
|
|
contentCollapsed = true
|
2023-02-04 20:22:29 +01:00
|
|
|
),
|
2022-01-11 19:00:29 +01:00
|
|
|
account = mockedStatus.account.toEntity(
|
|
|
|
accountId = userId,
|
|
|
|
gson = gson
|
|
|
|
)
|
2023-02-04 20:22:29 +01:00
|
|
|
)
|
2022-01-11 19:00:29 +01:00
|
|
|
}
|
2022-02-03 18:51:15 +01:00
|
|
|
|
|
|
|
fun mockPlaceholderEntityWithAccount(
|
|
|
|
id: String,
|
2023-03-13 13:16:39 +01:00
|
|
|
userId: Long = 1
|
2022-02-03 18:51:15 +01:00
|
|
|
): TimelineStatusWithAccount {
|
2023-02-04 20:22:29 +01:00
|
|
|
return TimelineStatusWithAccount(
|
2022-02-03 18:51:15 +01:00
|
|
|
status = Placeholder(id, false).toEntity(userId)
|
2023-02-04 20:22:29 +01:00
|
|
|
)
|
2022-02-03 18:51:15 +01:00
|
|
|
}
|