Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leaks on viewing a post from a notification #21013

Merged
merged 1 commit into from
Jul 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ReaderCommentsFollowPresenter: NSObject {

private let post: ReaderPost
private weak var delegate: ReaderCommentsFollowPresenterDelegate?
private let presentingViewController: UIViewController
private unowned let presentingViewController: UIViewController
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you chose unowned so the type didn't have to become wrapped in Optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. Given this is a "presenter" type, it should not use the view controller reference if the view controller is released. If this unowned reference causes a runtime crash in the production app, I think we may have other issues.

private let followCommentsService: FollowCommentsService?

// MARK: - Initialization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ReaderDetailCommentsTableViewDelegate: NSObject, UITableViewDataSource, UI

private(set) var totalComments = 0
private var post: ReaderPost?
private var presentingViewController: UIViewController?
private weak var presentingViewController: UIViewController?
private weak var buttonDelegate: BorderedButtonTableViewCellDelegate?
private(set) var headerView: ReaderDetailCommentsHeader?
var followButtonTappedClosure: (() ->Void)?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import UIKit
import AutomatticTracks

protocol ReaderDetailHeaderViewDelegate {
protocol ReaderDetailHeaderViewDelegate: AnyObject {
func didTapBlogName()
func didTapMenuButton(_ sender: UIView)
func didTapHeaderAvatar()
Expand Down Expand Up @@ -43,7 +43,7 @@ class ReaderDetailHeaderView: UIStackView, NibLoadable {

/// Any interaction with the header is sent to the delegate
///
var delegate: ReaderDetailHeaderViewDelegate?
weak var delegate: ReaderDetailHeaderViewDelegate?

func configure(for post: ReaderPost) {
self.post = post
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import UIKit

protocol ReaderDetailLikesViewDelegate {
protocol ReaderDetailLikesViewDelegate: AnyObject {
func didTapLikesView()
}

Expand All @@ -13,7 +13,7 @@ class ReaderDetailLikesView: UIView, NibLoadable {
@IBOutlet private weak var selfAvatarImageView: CircularImageView!

static let maxAvatarsDisplayed = 5
var delegate: ReaderDetailLikesViewDelegate?
weak var delegate: ReaderDetailLikesViewDelegate?

/// Stores the number of total likes _without_ adding the like from self.
private var totalLikes: Int = 0
Expand Down