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