Fix retain cycle in timestamp updating code
The timestamp update work item shouldn't retain a reference to the cell. It can be unowned because when the cell is deinit'd, the work item will be cancelled.
This commit is contained in:
parent
32e89f2c16
commit
8eb6f6f573
|
@ -27,6 +27,10 @@ class ActionNotificationGroupTableViewCell: UITableViewCell {
|
|||
var authorAvatarURL: URL?
|
||||
var updateTimestampWorkItem: DispatchWorkItem?
|
||||
|
||||
deinit {
|
||||
updateTimestampWorkItem?.cancel()
|
||||
}
|
||||
|
||||
override func awakeFromNib() {
|
||||
super.awakeFromNib()
|
||||
|
||||
|
@ -110,7 +114,9 @@ class ActionNotificationGroupTableViewCell: UITableViewCell {
|
|||
delay = nil
|
||||
}
|
||||
if let delay = delay {
|
||||
updateTimestampWorkItem = DispatchWorkItem(block: self.updateTimestamp)
|
||||
updateTimestampWorkItem = DispatchWorkItem { [unowned self] in
|
||||
self.updateTimestamp()
|
||||
}
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: updateTimestampWorkItem!)
|
||||
} else {
|
||||
updateTimestampWorkItem = nil
|
||||
|
|
|
@ -22,6 +22,10 @@ class FollowNotificationGroupTableViewCell: UITableViewCell {
|
|||
|
||||
var updateTimestampWorkItem: DispatchWorkItem?
|
||||
|
||||
deinit {
|
||||
updateTimestampWorkItem?.cancel()
|
||||
}
|
||||
|
||||
override func awakeFromNib() {
|
||||
super.awakeFromNib()
|
||||
|
||||
|
@ -98,7 +102,7 @@ class FollowNotificationGroupTableViewCell: UITableViewCell {
|
|||
delay = nil
|
||||
}
|
||||
if let delay = delay {
|
||||
updateTimestampWorkItem = DispatchWorkItem {
|
||||
updateTimestampWorkItem = DispatchWorkItem { [unowned self] in
|
||||
self.updateTimestamp()
|
||||
}
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: updateTimestampWorkItem!)
|
||||
|
|
|
@ -27,6 +27,10 @@ class FollowRequestNotificationTableViewCell: UITableViewCell {
|
|||
|
||||
var updateTimestampWorkItem: DispatchWorkItem?
|
||||
|
||||
deinit {
|
||||
updateTimestampWorkItem?.cancel()
|
||||
}
|
||||
|
||||
override func awakeFromNib() {
|
||||
super.awakeFromNib()
|
||||
|
||||
|
@ -72,7 +76,9 @@ class FollowRequestNotificationTableViewCell: UITableViewCell {
|
|||
delay = nil
|
||||
}
|
||||
if let delay = delay {
|
||||
updateTimestampWorkItem = DispatchWorkItem(block: self.updateTimestamp)
|
||||
updateTimestampWorkItem = DispatchWorkItem { [unowned self] in
|
||||
self.updateTimestamp()
|
||||
}
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: updateTimestampWorkItem!)
|
||||
} else {
|
||||
updateTimestampWorkItem = nil
|
||||
|
|
|
@ -34,6 +34,7 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell {
|
|||
|
||||
deinit {
|
||||
rebloggerAccountUpdater?.cancel()
|
||||
updateTimestampWorkItem?.cancel()
|
||||
}
|
||||
|
||||
override func awakeFromNib() {
|
||||
|
@ -109,7 +110,7 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell {
|
|||
delay = nil
|
||||
}
|
||||
if let delay = delay {
|
||||
updateTimestampWorkItem = DispatchWorkItem {
|
||||
updateTimestampWorkItem = DispatchWorkItem { [unowned self] in
|
||||
self.updateTimestamp()
|
||||
}
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: updateTimestampWorkItem!)
|
||||
|
|
Loading…
Reference in New Issue