From d9a2effff65bd391988da92cad9c2d70d13e2667 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 20 Mar 2018 10:25:37 -0400 Subject: [PATCH] CR: remove "k" from non constant // FREEBIE --- Signal/src/ViewControllers/DebugUI/DebugUIMessages.m | 3 ++- .../ViewControllers/MediaTileViewController.swift | 12 ++++++------ SignalServiceKit/src/Util/NSDate+OWS.h | 1 + 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Signal/src/ViewControllers/DebugUI/DebugUIMessages.m b/Signal/src/ViewControllers/DebugUI/DebugUIMessages.m index a41816cc2..1bb159efb 100644 --- a/Signal/src/ViewControllers/DebugUI/DebugUIMessages.m +++ b/Signal/src/ViewControllers/DebugUI/DebugUIMessages.m @@ -10,6 +10,7 @@ #import #import #import +#import #import #import #import @@ -1200,7 +1201,7 @@ NS_ASSUME_NONNULL_BEGIN for (NSUInteger i = 0; i < counter; i++) { // Random time within last n years. Helpful for filling out a media gallery over time. - double yearsMillis = 4.0 * 365.0 * 24.0 * 60.0 * 60.0 * 1000.0; + double yearsMillis = 4.0 * kYearsInMillis; uint64_t millisAgo = (uint64_t)(((double)arc4random() / ((double)0xffffffff)) * yearsMillis); uint64_t timestamp = [NSDate ows_millisecondTimeStamp] - millisAgo; diff --git a/Signal/src/ViewControllers/MediaTileViewController.swift b/Signal/src/ViewControllers/MediaTileViewController.swift index 27e75685a..d739cc2c6 100644 --- a/Signal/src/ViewControllers/MediaTileViewController.swift +++ b/Signal/src/ViewControllers/MediaTileViewController.swift @@ -155,7 +155,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryCe return 0 } - if sectionIdx == kLoadNewerSectionIdx { + if sectionIdx == loadNewerSectionIdx { // load more recent return 0 } @@ -187,7 +187,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryCe let title = NSLocalizedString("GALLERY_TILES_LOADING_OLDER_LABEL", comment: "Label indicating loading is in progress") sectionHeader.configure(title: title) return sectionHeader - case kLoadNewerSectionIdx: + case loadNewerSectionIdx: guard let sectionHeader = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: MediaGalleryLoadingHeader.reuseIdentifier, for: indexPath) as? MediaGalleryLoadingHeader else { owsFail("\(logTag) in \(#function) unable to build section header for kLoadOlderSectionIdx") @@ -223,8 +223,8 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryCe case kLoadOlderSectionIdx: owsFail("\(logTag) in \(#function) unexpected cell for kLoadOlderSectionIdx") return defaultCell - case kLoadNewerSectionIdx: - owsFail("\(logTag) in \(#function) unexpected cell for kLoadNewerSectionIdx") + case loadNewerSectionIdx: + owsFail("\(logTag) in \(#function) unexpected cell for loadNewerSectionIdx") return defaultCell default: guard let sectionDate = self.galleryDates[safe: indexPath.section - 1] else { @@ -269,7 +269,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryCe return CGSize.zero } return mediaGalleryDataSource.hasFetchedOldest ? CGSize.zero : CGSize(width: 0, height: 100) - case kLoadNewerSectionIdx: + case loadNewerSectionIdx: // Show "loading newer..." iff there is still more recent data to be fetched guard let mediaGalleryDataSource = self.mediaGalleryDataSource else { owsFail("\(logTag) in \(#function) mediaGalleryDataSource was unexpectedly nil") @@ -311,7 +311,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryCe var isFetchingMoreData: Bool = false let kLoadOlderSectionIdx = 0 - var kLoadNewerSectionIdx: Int { + var loadNewerSectionIdx: Int { return galleryDates.count + 1 } diff --git a/SignalServiceKit/src/Util/NSDate+OWS.h b/SignalServiceKit/src/Util/NSDate+OWS.h index d11100340..338e9d205 100755 --- a/SignalServiceKit/src/Util/NSDate+OWS.h +++ b/SignalServiceKit/src/Util/NSDate+OWS.h @@ -17,6 +17,7 @@ extern const NSTimeInterval kMonthInterval; #define kDayInMs (kHourInMs * 24) #define kWeekInMs (kDayInMs * 7) #define kMonthInMs (kDayInMs * 30) +#define kYearsInMs (kDayInMs * 365) @interface NSDate (OWS)