Fix status thread CW not shown and interacted status not updated (IOS-208, IOS-210)
This commit is contained in:
parent
b0bdaac8b4
commit
ab689d3c02
|
@ -30,7 +30,33 @@ extension ThreadViewController: DataSourceProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
func update(status: MastodonStatus) {
|
func update(status: MastodonStatus) {
|
||||||
viewModel.root = .root(context: .init(status: status))
|
switch viewModel.root {
|
||||||
|
case let .root(context):
|
||||||
|
if context.status.id == status.id {
|
||||||
|
viewModel.root = .root(context: .init(status: status))
|
||||||
|
} else {
|
||||||
|
handle(status: status)
|
||||||
|
}
|
||||||
|
case let .reply(context):
|
||||||
|
if context.status.id == status.id {
|
||||||
|
viewModel.root = .reply(context: .init(status: status))
|
||||||
|
} else {
|
||||||
|
handle(status: status)
|
||||||
|
}
|
||||||
|
case let .leaf(context):
|
||||||
|
if context.status.id == status.id {
|
||||||
|
viewModel.root = .leaf(context: .init(status: status))
|
||||||
|
} else {
|
||||||
|
handle(status: status)
|
||||||
|
}
|
||||||
|
case .none:
|
||||||
|
assertionFailure("This should not have happened")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func handle(status: MastodonStatus) {
|
||||||
|
viewModel.mastodonStatusThreadViewModel.ancestors.handle(status: status, for: viewModel)
|
||||||
|
viewModel.mastodonStatusThreadViewModel.descendants.handle(status: status, for: viewModel)
|
||||||
}
|
}
|
||||||
|
|
||||||
func delete(status: MastodonStatus) {
|
func delete(status: MastodonStatus) {
|
||||||
|
@ -42,3 +68,41 @@ extension ThreadViewController: DataSourceProvider {
|
||||||
return tableView.indexPath(for: cell)
|
return tableView.indexPath(for: cell)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private extension [StatusItem] {
|
||||||
|
mutating func handle(status: MastodonStatus, for viewModel: ThreadViewModel) {
|
||||||
|
for (index, ancestor) in enumerated() {
|
||||||
|
switch ancestor {
|
||||||
|
case let .feed(record):
|
||||||
|
if record.status?.id == status.id {
|
||||||
|
self[index] = .feed(record: .fromStatus(status, kind: record.kind))
|
||||||
|
}
|
||||||
|
case let.feedLoader(record):
|
||||||
|
if record.status?.id == status.id {
|
||||||
|
self[index] = .feedLoader(record: .fromStatus(status, kind: record.kind))
|
||||||
|
}
|
||||||
|
case let .status(record):
|
||||||
|
if record.id == status.id {
|
||||||
|
self[index] = .status(record: status)
|
||||||
|
}
|
||||||
|
case let .thread(thread):
|
||||||
|
switch thread {
|
||||||
|
case let .root(context):
|
||||||
|
if context.status.id == status.id {
|
||||||
|
self[index] = .thread(.root(context: .init(status: status)))
|
||||||
|
}
|
||||||
|
case let .reply(context):
|
||||||
|
if context.status.id == status.id {
|
||||||
|
self[index] = .thread(.reply(context: .init(status: status)))
|
||||||
|
}
|
||||||
|
case let .leaf(context):
|
||||||
|
if context.status.id == status.id {
|
||||||
|
self[index] = .thread(.leaf(context: .init(status: status)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case .bottomLoader, .topLoader:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue