marking a thread as read/unread via swipe gesture (and selecting the corresponding action) the badge indicating the read/unread status will be updated immediately.
This commit is contained in:
parent
affbdc8e55
commit
55fe01353a
@ -799,6 +799,7 @@ extension HVTableDataSource: UITableViewDataSource {
|
||||
readStateAction = UIContextualAction(style: .destructive,
|
||||
title: nil) { [weak viewController] (_, _, completion) in
|
||||
completion(false)
|
||||
NotificationCenter.default.post(name: HomeViewCell.TEMPORARY_CHANGE_UNREAD_BADGE, object: thread, userInfo: ["markAsRead": true])
|
||||
// We delay here so the animation can play out before we
|
||||
// reload the cell
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.65) { [weak viewController] in
|
||||
@ -813,6 +814,7 @@ extension HVTableDataSource: UITableViewDataSource {
|
||||
readStateAction = UIContextualAction(style: .normal,
|
||||
title: nil) { [weak viewController] (_, _, completion) in
|
||||
completion(false)
|
||||
NotificationCenter.default.post(name: HomeViewCell.TEMPORARY_CHANGE_UNREAD_BADGE, object: thread, userInfo: ["markAsRead": false])
|
||||
// We delay here so the animation can play out before we
|
||||
// reload the cell
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.65) { [weak viewController] in
|
||||
|
||||
@ -9,6 +9,8 @@ import SignalUI
|
||||
@objc
|
||||
public class HomeViewCell: UITableViewCell {
|
||||
|
||||
static let TEMPORARY_CHANGE_UNREAD_BADGE = NSNotification.Name(rawValue: "TEMPORARY_CHANGE_UNREAD_BADGE")
|
||||
|
||||
@objc
|
||||
public static let reuseIdentifier = "HomeViewCell"
|
||||
|
||||
@ -208,6 +210,7 @@ public class HomeViewCell: UITableViewCell {
|
||||
hasOverrideSnippet: configuration.hasOverrideSnippet,
|
||||
messageStatusToken: messageStatusToken,
|
||||
unreadIndicatorLabelConfig: unreadIndicatorLabelConfig,
|
||||
hideUnreadIndicator: configuration.hasOverrideSnippet || !configuration.thread.hasUnreadMessages,
|
||||
|
||||
topRowStackConfig: Self.topRowStackConfig,
|
||||
bottomRowStackConfig: Self.bottomRowStackConfig,
|
||||
@ -361,6 +364,10 @@ public class HomeViewCell: UITableViewCell {
|
||||
selector: #selector(typingIndicatorStateDidChange),
|
||||
name: TypingIndicatorsImpl.typingIndicatorStateDidChange,
|
||||
object: nil)
|
||||
NotificationCenter.default.addObserver(self,
|
||||
selector: #selector(temporarySetUnreadIndicator(notification:)),
|
||||
name: HomeViewCell.TEMPORARY_CHANGE_UNREAD_BADGE,
|
||||
object: thread)
|
||||
|
||||
// The top row contains:
|
||||
//
|
||||
@ -433,6 +440,7 @@ public class HomeViewCell: UITableViewCell {
|
||||
let unreadBadgeMeasurements = measurements.unreadBadgeMeasurements {
|
||||
let unreadBadge = configureUnreadBadge(unreadIndicatorLabelConfig: unreadIndicatorLabelConfig,
|
||||
unreadBadgeMeasurements: unreadBadgeMeasurements)
|
||||
unreadBadge.alpha = configs.hideUnreadIndicator ? 0 : 1
|
||||
bottomRowStackSubviews.append(unreadBadge)
|
||||
}
|
||||
|
||||
@ -617,14 +625,7 @@ public class HomeViewCell: UITableViewCell {
|
||||
private static func buildUnreadIndicatorLabelConfig(configuration: Configuration) -> CVLabelConfig? {
|
||||
let text: String
|
||||
switch configuration.unreadMode {
|
||||
case .none:
|
||||
// If we're using the conversation list cell to render search results,
|
||||
// don't show "unread badge" or "message status" indicator.
|
||||
//
|
||||
// Or there might simply be no unread messages / the thread is not
|
||||
// marked as unread.
|
||||
return nil
|
||||
case .unreadWithoutCount:
|
||||
case .none, .unreadWithoutCount:
|
||||
text = ""
|
||||
case .unreadWithCount(let unreadCount):
|
||||
text = unreadCount > 0 ? OWSFormat.formatUInt(unreadCount) : ""
|
||||
@ -898,6 +899,13 @@ public class HomeViewCell: UITableViewCell {
|
||||
updateTypingIndicatorState()
|
||||
}
|
||||
|
||||
@objc
|
||||
private func temporarySetUnreadIndicator(notification: Notification) {
|
||||
AssertIsOnMainThread()
|
||||
let markAsRead = notification.userInfo?["markAsRead"] as? Bool ?? false
|
||||
unreadBadge.alpha = markAsRead ? 0 : 1
|
||||
}
|
||||
|
||||
// MARK: - Typing Indicators
|
||||
|
||||
private var shouldShowTypingIndicators: Bool {
|
||||
@ -956,6 +964,7 @@ private struct HVCellConfigs {
|
||||
let hasOverrideSnippet: Bool
|
||||
let messageStatusToken: HVMessageStatusToken?
|
||||
let unreadIndicatorLabelConfig: CVLabelConfig?
|
||||
let hideUnreadIndicator: Bool
|
||||
|
||||
// Configs
|
||||
let topRowStackConfig: ManualStackView.Config
|
||||
|
||||
Loading…
Reference in New Issue
Block a user