1
0
mirror of https://github.com/metabolist/metatext synced 2024-12-27 10:12:36 +01:00

Improve reply indicator logic

This commit is contained in:
Justin Mazzocchi 2020-10-24 23:18:35 -07:00
parent 8ad01a6ecf
commit 3a1d8d4470
No known key found for this signature in database
GPG Key ID: E223E6937AAFB01C

View File

@ -28,16 +28,26 @@ extension ContextItemsInfo {
section.filtered(regularExpression: regularExpression)
.enumerated()
.map { index, statusInfo in
let isReplyInContext = index > 0
&& section[index - 1].record.id == statusInfo.record.inReplyToId
let hasReplyFollowing = section.count > index + 1
&& section[index + 1].record.inReplyToId == statusInfo.record.id
let isContextParent = statusInfo.record.id == parent.record.id
let isReplyInContext: Bool
if isContextParent {
isReplyInContext = !ancestors.isEmpty
&& statusInfo.record.inReplyToId == ancestors.last?.record.id
} else {
isReplyInContext = index > 0
&& section[index - 1].record.id == statusInfo.record.inReplyToId
}
let hasReplyFollowing = (section.count > index + 1
&& section[index + 1].record.inReplyToId == statusInfo.record.id)
|| (statusInfo == ancestors.last && parent.record.inReplyToId == statusInfo.record.id)
return .status(
.init(info: statusInfo),
.init(showContentToggled: statusInfo.showContentToggled,
showAttachmentsToggled: statusInfo.showAttachmentsToggled,
isContextParent: statusInfo.record.id == parent.record.id,
isContextParent: isContextParent,
isReplyInContext: isReplyInContext,
hasReplyFollowing: hasReplyFollowing))
}