fix: memery leak
This commit is contained in:
parent
ad8df6813f
commit
7eb79414a4
|
@ -36,7 +36,8 @@ extension ReportSection {
|
|||
cell.dependency = dependency
|
||||
let activeMastodonAuthenticationBox = dependency.context.authenticationService.activeMastodonAuthenticationBox.value
|
||||
let requestUserID = activeMastodonAuthenticationBox?.userID ?? ""
|
||||
managedObjectContext.performAndWait {
|
||||
managedObjectContext.performAndWait { [weak dependency] in
|
||||
guard let dependency = dependency else { return }
|
||||
let status = managedObjectContext.object(with: objectID) as! Status
|
||||
StatusSection.configure(
|
||||
cell: cell,
|
||||
|
|
|
@ -149,7 +149,8 @@ extension StatusSection {
|
|||
.receive(on: DispatchQueue.main)
|
||||
.sink { _ in
|
||||
// do nothing
|
||||
} receiveValue: { change in
|
||||
} receiveValue: { [weak cell] change in
|
||||
guard let cell = cell else { return }
|
||||
guard case .update(let object) = change.changeType,
|
||||
let newStatus = object as? Status else { return }
|
||||
StatusSection.configureHeader(cell: cell, status: newStatus)
|
||||
|
@ -221,7 +222,8 @@ extension StatusSection {
|
|||
} else {
|
||||
meta.blurhashImagePublisher()
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { image in
|
||||
.sink { [weak cell] image in
|
||||
guard let cell = cell else { return }
|
||||
blurhashOverlayImageView.image = image
|
||||
image?.pngData().flatMap {
|
||||
blurhashImageCache.setObject($0 as NSData, forKey: blurhashImageDataKey)
|
||||
|
@ -246,7 +248,8 @@ extension StatusSection {
|
|||
statusItemAttribute.isRevealing
|
||||
)
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { isImageLoaded, isMediaRevealing in
|
||||
.sink { [weak cell] isImageLoaded, isMediaRevealing in
|
||||
guard let cell = cell else { return }
|
||||
guard isImageLoaded else {
|
||||
blurhashOverlayImageView.alpha = 1
|
||||
blurhashOverlayImageView.isHidden = false
|
||||
|
@ -355,7 +358,8 @@ extension StatusSection {
|
|||
.receive(on: DispatchQueue.main)
|
||||
.sink { _ in
|
||||
// do nothing
|
||||
} receiveValue: { [weak dependency] change in
|
||||
} receiveValue: { [weak dependency, weak cell] change in
|
||||
guard let cell = cell else { return }
|
||||
guard let dependency = dependency else { return }
|
||||
guard case .update(let object) = change.changeType,
|
||||
let status = object as? Status else { return }
|
||||
|
@ -382,7 +386,8 @@ extension StatusSection {
|
|||
ManagedObjectObserver.observe(object: poll)
|
||||
.sink { _ in
|
||||
// do nothing
|
||||
} receiveValue: { change in
|
||||
} receiveValue: { [weak cell] change in
|
||||
guard let cell = cell else { return }
|
||||
guard case .update(let object) = change.changeType,
|
||||
let newPoll = object as? Poll else { return }
|
||||
StatusSection.configurePoll(
|
||||
|
@ -413,7 +418,8 @@ extension StatusSection {
|
|||
let createdAt = (status.reblog ?? status).createdAt
|
||||
cell.statusView.dateLabel.text = createdAt.shortTimeAgoSinceNow
|
||||
timestampUpdatePublisher
|
||||
.sink { _ in
|
||||
.sink { [weak cell] _ in
|
||||
guard let cell = cell else { return }
|
||||
cell.statusView.dateLabel.text = createdAt.shortTimeAgoSinceNow
|
||||
}
|
||||
.store(in: &cell.disposeBag)
|
||||
|
@ -423,7 +429,9 @@ extension StatusSection {
|
|||
.receive(on: DispatchQueue.main)
|
||||
.sink { _ in
|
||||
// do nothing
|
||||
} receiveValue: { change in
|
||||
} receiveValue: { [weak dependency, weak cell] change in
|
||||
guard let cell = cell else { return }
|
||||
guard let dependency = dependency else { return }
|
||||
guard case .update(let object) = change.changeType,
|
||||
let status = object as? Status else { return }
|
||||
StatusSection.configureActionToolBar(
|
||||
|
@ -759,7 +767,9 @@ extension StatusSection {
|
|||
}
|
||||
var children: [UIMenuElement] = []
|
||||
let name = author.displayNameWithFallback
|
||||
let reportAction = UIAction(title: L10n.Common.Controls.Actions.reportUser(name), image: UIImage(systemName: "exclamationmark.bubble"), identifier: nil, discoverabilityTitle: nil, attributes: [], state: .off) { _ in
|
||||
let reportAction = UIAction(title: L10n.Common.Controls.Actions.reportUser(name), image: UIImage(systemName: "exclamationmark.bubble"), identifier: nil, discoverabilityTitle: nil, attributes: [], state: .off) {
|
||||
[weak dependency] _ in
|
||||
guard let dependency = dependency else { return }
|
||||
let viewModel = ReportViewModel(
|
||||
context: dependency.context,
|
||||
domain: authenticationBox.domain,
|
||||
|
|
|
@ -133,13 +133,11 @@ class ReportViewModel: NSObject {
|
|||
}
|
||||
.store(in: &disposeBag)
|
||||
|
||||
input.comment.assign(
|
||||
to: \.comment,
|
||||
on: self
|
||||
)
|
||||
.store(in: &disposeBag)
|
||||
input.comment.sink { [weak self] (comment) in
|
||||
guard let self = self else { return }
|
||||
|
||||
self.comment = comment
|
||||
|
||||
let sendEnable = (comment?.length ?? 0) > 0
|
||||
self.sendEnableSubject.send(sendEnable)
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ final class ReportedStatusTableViewCell: UITableViewCell, StatusCell {
|
|||
|
||||
static let bottomPaddingHeight: CGFloat = 10
|
||||
|
||||
var dependency: ReportViewController?
|
||||
weak var dependency: ReportViewController?
|
||||
var disposeBag = Set<AnyCancellable>()
|
||||
var pollCountdownSubscription: AnyCancellable?
|
||||
var observations = Set<NSKeyValueObservation>()
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
// Created by MainasuK Cirno on 2021-4-6.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
final class TimelineHeaderView: UIView {
|
||||
|
||||
let iconImageView: UIImageView = {
|
||||
|
|
Loading…
Reference in New Issue