Make edit stickier

This commit is contained in:
Thomas Ricouard 2024-01-01 14:13:25 +01:00
parent b93df71431
commit b10ee3091c
3 changed files with 7 additions and 2 deletions

View file

@ -57,6 +57,7 @@ public final class StatusDataControllerProvider {
public var isReblogged: Bool public var isReblogged: Bool
public var isBookmarked: Bool public var isBookmarked: Bool
public var isFavorited: Bool public var isFavorited: Bool
public var content: HTMLString
public var favoritesCount: Int public var favoritesCount: Int
public var reblogsCount: Int public var reblogsCount: Int
@ -73,6 +74,7 @@ public final class StatusDataControllerProvider {
reblogsCount = status.reblogsCount reblogsCount = status.reblogsCount
repliesCount = status.repliesCount repliesCount = status.repliesCount
favoritesCount = status.favouritesCount favoritesCount = status.favouritesCount
content = status.content
} }
public func updateFrom(status: AnyStatus) { public func updateFrom(status: AnyStatus) {
@ -83,6 +85,7 @@ public final class StatusDataControllerProvider {
reblogsCount = status.reblogsCount reblogsCount = status.reblogsCount
repliesCount = status.repliesCount repliesCount = status.repliesCount
favoritesCount = status.favouritesCount favoritesCount = status.favouritesCount
content = status.content
} }
public func toggleFavorite(remoteStatus: String?) async { public func toggleFavorite(remoteStatus: String?) async {

View file

@ -122,6 +122,7 @@ public struct StatusDetailView: View {
let isFocused = self.viewModel.statusId == status.id let isFocused = self.viewModel.statusId == status.id
StatusRowView(viewModel: viewModel) StatusRowView(viewModel: viewModel)
.id(status.id + (status.editedAt?.asDate.description ?? ""))
.environment(\.extraLeadingInset, !isCompact ? extraInsets : 0) .environment(\.extraLeadingInset, !isCompact ? extraInsets : 0)
.environment(\.indentationLevel, !isCompact ? indentationLevel : 0) .environment(\.indentationLevel, !isCompact ? indentationLevel : 0)
.environment(\.isStatusFocused, isFocused) .environment(\.isStatusFocused, isFocused)
@ -135,7 +136,6 @@ public struct StatusDetailView: View {
} }
} }
} }
.id(status.id)
#if !os(visionOS) #if !os(visionOS)
.listRowBackground(viewModel.highlightRowColor) .listRowBackground(viewModel.highlightRowColor)
#endif #endif

View file

@ -7,13 +7,15 @@ import SwiftUI
struct StatusRowTextView: View { struct StatusRowTextView: View {
@Environment(Theme.self) private var theme @Environment(Theme.self) private var theme
@Environment(\.isStatusFocused) private var isFocused @Environment(\.isStatusFocused) private var isFocused
@Environment(StatusDataController.self) private var statusDataController
var viewModel: StatusRowViewModel var viewModel: StatusRowViewModel
var body: some View { var body: some View {
VStack { VStack {
HStack { HStack {
EmojiTextApp(viewModel.finalStatus.content, EmojiTextApp(statusDataController.content,
emojis: viewModel.finalStatus.emojis, emojis: viewModel.finalStatus.emojis,
language: viewModel.finalStatus.language, language: viewModel.finalStatus.language,
lineLimit: viewModel.lineLimit) lineLimit: viewModel.lineLimit)