forked from shadowfacts/Tusker
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 authorAvatarURL: URL?
|
||||||
var updateTimestampWorkItem: DispatchWorkItem?
|
var updateTimestampWorkItem: DispatchWorkItem?
|
||||||
|
|
||||||
|
deinit {
|
||||||
|
updateTimestampWorkItem?.cancel()
|
||||||
|
}
|
||||||
|
|
||||||
override func awakeFromNib() {
|
override func awakeFromNib() {
|
||||||
super.awakeFromNib()
|
super.awakeFromNib()
|
||||||
|
|
||||||
|
@ -110,7 +114,9 @@ class ActionNotificationGroupTableViewCell: UITableViewCell {
|
||||||
delay = nil
|
delay = nil
|
||||||
}
|
}
|
||||||
if let delay = delay {
|
if let delay = delay {
|
||||||
updateTimestampWorkItem = DispatchWorkItem(block: self.updateTimestamp)
|
updateTimestampWorkItem = DispatchWorkItem { [unowned self] in
|
||||||
|
self.updateTimestamp()
|
||||||
|
}
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: updateTimestampWorkItem!)
|
DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: updateTimestampWorkItem!)
|
||||||
} else {
|
} else {
|
||||||
updateTimestampWorkItem = nil
|
updateTimestampWorkItem = nil
|
||||||
|
|
|
@ -22,6 +22,10 @@ class FollowNotificationGroupTableViewCell: UITableViewCell {
|
||||||
|
|
||||||
var updateTimestampWorkItem: DispatchWorkItem?
|
var updateTimestampWorkItem: DispatchWorkItem?
|
||||||
|
|
||||||
|
deinit {
|
||||||
|
updateTimestampWorkItem?.cancel()
|
||||||
|
}
|
||||||
|
|
||||||
override func awakeFromNib() {
|
override func awakeFromNib() {
|
||||||
super.awakeFromNib()
|
super.awakeFromNib()
|
||||||
|
|
||||||
|
@ -98,7 +102,7 @@ class FollowNotificationGroupTableViewCell: UITableViewCell {
|
||||||
delay = nil
|
delay = nil
|
||||||
}
|
}
|
||||||
if let delay = delay {
|
if let delay = delay {
|
||||||
updateTimestampWorkItem = DispatchWorkItem {
|
updateTimestampWorkItem = DispatchWorkItem { [unowned self] in
|
||||||
self.updateTimestamp()
|
self.updateTimestamp()
|
||||||
}
|
}
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: updateTimestampWorkItem!)
|
DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: updateTimestampWorkItem!)
|
||||||
|
|
|
@ -27,6 +27,10 @@ class FollowRequestNotificationTableViewCell: UITableViewCell {
|
||||||
|
|
||||||
var updateTimestampWorkItem: DispatchWorkItem?
|
var updateTimestampWorkItem: DispatchWorkItem?
|
||||||
|
|
||||||
|
deinit {
|
||||||
|
updateTimestampWorkItem?.cancel()
|
||||||
|
}
|
||||||
|
|
||||||
override func awakeFromNib() {
|
override func awakeFromNib() {
|
||||||
super.awakeFromNib()
|
super.awakeFromNib()
|
||||||
|
|
||||||
|
@ -72,7 +76,9 @@ class FollowRequestNotificationTableViewCell: UITableViewCell {
|
||||||
delay = nil
|
delay = nil
|
||||||
}
|
}
|
||||||
if let delay = delay {
|
if let delay = delay {
|
||||||
updateTimestampWorkItem = DispatchWorkItem(block: self.updateTimestamp)
|
updateTimestampWorkItem = DispatchWorkItem { [unowned self] in
|
||||||
|
self.updateTimestamp()
|
||||||
|
}
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: updateTimestampWorkItem!)
|
DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: updateTimestampWorkItem!)
|
||||||
} else {
|
} else {
|
||||||
updateTimestampWorkItem = nil
|
updateTimestampWorkItem = nil
|
||||||
|
|
|
@ -34,6 +34,7 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell {
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
rebloggerAccountUpdater?.cancel()
|
rebloggerAccountUpdater?.cancel()
|
||||||
|
updateTimestampWorkItem?.cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
override func awakeFromNib() {
|
override func awakeFromNib() {
|
||||||
|
@ -109,7 +110,7 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell {
|
||||||
delay = nil
|
delay = nil
|
||||||
}
|
}
|
||||||
if let delay = delay {
|
if let delay = delay {
|
||||||
updateTimestampWorkItem = DispatchWorkItem {
|
updateTimestampWorkItem = DispatchWorkItem { [unowned self] in
|
||||||
self.updateTimestamp()
|
self.updateTimestamp()
|
||||||
}
|
}
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: updateTimestampWorkItem!)
|
DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: updateTimestampWorkItem!)
|
||||||
|
|
Loading…
Reference in New Issue