fix: safely cancel the listenser for status
This commit is contained in:
parent
d3256f3171
commit
04eeb0100e
|
@ -143,6 +143,21 @@ extension StatusSection {
|
||||||
requestUserID: String,
|
requestUserID: String,
|
||||||
statusItemAttribute: Item.StatusAttribute
|
statusItemAttribute: Item.StatusAttribute
|
||||||
) {
|
) {
|
||||||
|
// safely cancel the listenser when deleted
|
||||||
|
ManagedObjectObserver.observe(object: status.reblog ?? status)
|
||||||
|
.receive(on: DispatchQueue.main)
|
||||||
|
.sink { _ in
|
||||||
|
// do nothing
|
||||||
|
} receiveValue: { [weak cell] change in
|
||||||
|
guard let cell = cell else { return }
|
||||||
|
guard let changeType = change.changeType else { return }
|
||||||
|
if case .delete = changeType {
|
||||||
|
cell.disposeBag.removeAll()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.store(in: &cell.disposeBag)
|
||||||
|
|
||||||
|
|
||||||
// set header
|
// set header
|
||||||
StatusSection.configureHeader(cell: cell, status: status)
|
StatusSection.configureHeader(cell: cell, status: status)
|
||||||
ManagedObjectObserver.observe(object: status)
|
ManagedObjectObserver.observe(object: status)
|
||||||
|
|
Loading…
Reference in New Issue