Merge branch 'nt/little-fixes68' into release/3.11.0
This commit is contained in:
commit
5dc7d5f8d5
@ -64,7 +64,7 @@ public class DateHeaderCell: ConversationViewCell {
|
||||
titleLabel.font = .ows_dynamicTypeBody2
|
||||
titleLabel.textColor = Theme.primaryTextColor
|
||||
|
||||
let date = viewItem.interaction.receivedAtDate()
|
||||
let date = Date(millisecondsSince1970: viewItem.interaction.timestamp)
|
||||
let dateString = DateUtil.formatDate(forConversationDateBreaks: date)
|
||||
|
||||
titleLabel.text = dateString.localizedUppercase
|
||||
|
||||
@ -1137,19 +1137,17 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
__block BOOL hasPlacedUnreadIndicator = NO;
|
||||
__block BOOL shouldShowDateOnNextViewItem = YES;
|
||||
__block uint64_t previousViewItemReceivedAtTimestamp = 0;
|
||||
__block uint64_t previousViewItemTimestamp = 0;
|
||||
void (^addHeaderViewItemIfNecessary)(id<ConversationViewItem>) = ^(id<ConversationViewItem> viewItem) {
|
||||
uint64_t viewItemReceivedAtTimestamp = viewItem.interaction.receivedAtTimestamp;
|
||||
OWSAssertDebug(viewItemReceivedAtTimestamp > 0);
|
||||
uint64_t viewItemTimestamp = viewItem.interaction.timestamp;
|
||||
OWSAssertDebug(viewItemTimestamp > 0);
|
||||
|
||||
BOOL shouldShowDate = NO;
|
||||
if (previousViewItemReceivedAtTimestamp == 0) {
|
||||
if (previousViewItemTimestamp == 0) {
|
||||
// Only show for the first item if the date is not today
|
||||
shouldShowDateOnNextViewItem
|
||||
= ![DateUtil dateIsToday:[NSDate ows_dateWithMillisecondsSince1970:viewItemReceivedAtTimestamp]];
|
||||
} else if (![DateUtil isSameDayWithTimestamp:previousViewItemReceivedAtTimestamp
|
||||
timestamp:viewItemReceivedAtTimestamp]
|
||||
&& viewItemReceivedAtTimestamp > previousViewItemReceivedAtTimestamp) {
|
||||
= ![DateUtil dateIsToday:[NSDate ows_dateWithMillisecondsSince1970:viewItemTimestamp]];
|
||||
} else if (![DateUtil isSameDayWithTimestamp:previousViewItemTimestamp timestamp:viewItemTimestamp]) {
|
||||
shouldShowDateOnNextViewItem = YES;
|
||||
}
|
||||
|
||||
@ -1170,8 +1168,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
shouldShowDate:shouldShowDate];
|
||||
} else if (shouldShowDate) {
|
||||
interaction = [[OWSDateHeaderInteraction alloc] initWithThread:self.thread
|
||||
timestamp:viewItem.interaction.timestamp
|
||||
receivedAtTimestamp:viewItem.interaction.receivedAtTimestamp];
|
||||
timestamp:viewItem.interaction.timestamp];
|
||||
}
|
||||
|
||||
if (interaction) {
|
||||
@ -1180,7 +1177,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
[viewItems addObject:headerViewItem];
|
||||
}
|
||||
|
||||
previousViewItemReceivedAtTimestamp = viewItemReceivedAtTimestamp;
|
||||
previousViewItemTimestamp = viewItemTimestamp;
|
||||
};
|
||||
|
||||
__block BOOL hasError = NO;
|
||||
|
||||
@ -30,10 +30,9 @@ public class DateHeaderInteraction: TSInteraction {
|
||||
}
|
||||
|
||||
@objc
|
||||
public init(thread: TSThread, timestamp: UInt64, receivedAtTimestamp: UInt64) {
|
||||
public init(thread: TSThread, timestamp: UInt64) {
|
||||
super.init(uniqueId: "DateHeader_\(timestamp)",
|
||||
timestamp: timestamp,
|
||||
receivedAtTimestamp: receivedAtTimestamp,
|
||||
thread: thread)
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2020 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@ -19,4 +19,8 @@ public extension Date {
|
||||
static func ows_millisecondTimestamp() -> UInt64 {
|
||||
return NSDate.ows_millisecondTimeStamp()
|
||||
}
|
||||
|
||||
init(millisecondsSince1970: UInt64) {
|
||||
self = NSDate.ows_date(withMillisecondsSince1970: millisecondsSince1970) as Date
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user