diff --git a/Tusker/Views/Notifications/ActionNotificationGroupTableViewCell.swift b/Tusker/Views/Notifications/ActionNotificationGroupTableViewCell.swift index 62256c38..d4ea85cb 100644 --- a/Tusker/Views/Notifications/ActionNotificationGroupTableViewCell.swift +++ b/Tusker/Views/Notifications/ActionNotificationGroupTableViewCell.swift @@ -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 diff --git a/Tusker/Views/Notifications/FollowNotificationGroupTableViewCell.swift b/Tusker/Views/Notifications/FollowNotificationGroupTableViewCell.swift index 0113d78e..90d982fd 100644 --- a/Tusker/Views/Notifications/FollowNotificationGroupTableViewCell.swift +++ b/Tusker/Views/Notifications/FollowNotificationGroupTableViewCell.swift @@ -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!) diff --git a/Tusker/Views/Notifications/FollowRequestNotificationTableViewCell.swift b/Tusker/Views/Notifications/FollowRequestNotificationTableViewCell.swift index f62f71b1..f31fe7a1 100644 --- a/Tusker/Views/Notifications/FollowRequestNotificationTableViewCell.swift +++ b/Tusker/Views/Notifications/FollowRequestNotificationTableViewCell.swift @@ -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 diff --git a/Tusker/Views/Status/TimelineStatusTableViewCell.swift b/Tusker/Views/Status/TimelineStatusTableViewCell.swift index d4aa74ed..6e115f6c 100644 --- a/Tusker/Views/Status/TimelineStatusTableViewCell.swift +++ b/Tusker/Views/Status/TimelineStatusTableViewCell.swift @@ -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!)