mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
CR: rename ThreadModel -> ThreadViewModel
// FREEBIE
This commit is contained in:
parent
d1230abdc5
commit
f5e810e82b
|
@ -5,7 +5,7 @@
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
@objc
|
@objc
|
||||||
public class ThreadModel: NSObject {
|
public class ThreadViewModel: NSObject {
|
||||||
let hasUnreadMessages: Bool
|
let hasUnreadMessages: Bool
|
||||||
let lastMessageDate: Date
|
let lastMessageDate: Date
|
||||||
let isGroupThread: Bool
|
let isGroupThread: Bool
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@class OWSContactsManager;
|
@class OWSContactsManager;
|
||||||
@class ThreadModel;
|
@class ThreadViewModel;
|
||||||
@class YapDatabaseReadTransaction;
|
@class YapDatabaseReadTransaction;
|
||||||
|
|
||||||
@interface HomeViewCell : UITableViewCell
|
@interface HomeViewCell : UITableViewCell
|
||||||
|
@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
+ (NSString *)cellReuseIdentifier;
|
+ (NSString *)cellReuseIdentifier;
|
||||||
|
|
||||||
- (void)configureWithThread:(ThreadModel *)thread
|
- (void)configureWithThread:(ThreadViewModel *)thread
|
||||||
contactsManager:(OWSContactsManager *)contactsManager
|
contactsManager:(OWSContactsManager *)contactsManager
|
||||||
blockedPhoneNumberSet:(NSSet<NSString *> *)blockedPhoneNumberSet;
|
blockedPhoneNumberSet:(NSSet<NSString *> *)blockedPhoneNumberSet;
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
@property (nonatomic) UIView *unreadBadge;
|
@property (nonatomic) UIView *unreadBadge;
|
||||||
@property (nonatomic) UILabel *unreadLabel;
|
@property (nonatomic) UILabel *unreadLabel;
|
||||||
|
|
||||||
@property (nonatomic, nullable) ThreadModel *thread;
|
@property (nonatomic, nullable) ThreadViewModel *thread;
|
||||||
@property (nonatomic, nullable) OWSContactsManager *contactsManager;
|
@property (nonatomic, nullable) OWSContactsManager *contactsManager;
|
||||||
|
|
||||||
@property (nonatomic, readonly) NSMutableArray<NSLayoutConstraint *> *viewConstraints;
|
@property (nonatomic, readonly) NSMutableArray<NSLayoutConstraint *> *viewConstraints;
|
||||||
|
@ -142,7 +142,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
return NSStringFromClass(self.class);
|
return NSStringFromClass(self.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)configureWithThread:(ThreadModel *)thread
|
- (void)configureWithThread:(ThreadViewModel *)thread
|
||||||
contactsManager:(OWSContactsManager *)contactsManager
|
contactsManager:(OWSContactsManager *)contactsManager
|
||||||
blockedPhoneNumberSet:(NSSet<NSString *> *)blockedPhoneNumberSet
|
blockedPhoneNumberSet:(NSSet<NSString *> *)blockedPhoneNumberSet
|
||||||
{
|
{
|
||||||
|
@ -239,7 +239,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ThreadModel *thread = self.thread;
|
ThreadViewModel *thread = self.thread;
|
||||||
if (thread == nil) {
|
if (thread == nil) {
|
||||||
OWSFail(@"%@ thread should not be nil", self.logTag);
|
OWSFail(@"%@ thread should not be nil", self.logTag);
|
||||||
self.avatarView.image = nil;
|
self.avatarView.image = nil;
|
||||||
|
@ -251,7 +251,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
contactsManager:contactsManager];
|
contactsManager:contactsManager];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSAttributedString *)attributedSnippetForThread:(ThreadModel *)thread
|
- (NSAttributedString *)attributedSnippetForThread:(ThreadViewModel *)thread
|
||||||
blockedPhoneNumberSet:(NSSet<NSString *> *)blockedPhoneNumberSet
|
blockedPhoneNumberSet:(NSSet<NSString *> *)blockedPhoneNumberSet
|
||||||
{
|
{
|
||||||
OWSAssert(thread);
|
OWSAssert(thread);
|
||||||
|
@ -447,7 +447,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
self.nameLabel.font = self.nameFont;
|
self.nameLabel.font = self.nameFont;
|
||||||
|
|
||||||
ThreadModel *thread = self.thread;
|
ThreadViewModel *thread = self.thread;
|
||||||
if (thread == nil) {
|
if (thread == nil) {
|
||||||
OWSFail(@"%@ thread should not be nil", self.logTag);
|
OWSFail(@"%@ thread should not be nil", self.logTag);
|
||||||
self.nameLabel.attributedText = nil;
|
self.nameLabel.attributedText = nil;
|
||||||
|
|
|
@ -47,7 +47,7 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
||||||
@property (nonatomic) UISegmentedControl *segmentedControl;
|
@property (nonatomic) UISegmentedControl *segmentedControl;
|
||||||
@property (nonatomic) id previewingContext;
|
@property (nonatomic) id previewingContext;
|
||||||
@property (nonatomic) NSSet<NSString *> *blockedPhoneNumberSet;
|
@property (nonatomic) NSSet<NSString *> *blockedPhoneNumberSet;
|
||||||
@property (nonatomic, readonly) NSCache<NSString *, ThreadModel *> *threadModelCache;
|
@property (nonatomic, readonly) NSCache<NSString *, ThreadViewModel *> *threadViewModelCache;
|
||||||
@property (nonatomic) BOOL isViewVisible;
|
@property (nonatomic) BOOL isViewVisible;
|
||||||
@property (nonatomic) BOOL isAppInBackground;
|
@property (nonatomic) BOOL isAppInBackground;
|
||||||
@property (nonatomic) BOOL shouldObserveDBModifications;
|
@property (nonatomic) BOOL shouldObserveDBModifications;
|
||||||
|
@ -108,7 +108,7 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
||||||
_messageSender = [Environment current].messageSender;
|
_messageSender = [Environment current].messageSender;
|
||||||
_blockingManager = [OWSBlockingManager sharedManager];
|
_blockingManager = [OWSBlockingManager sharedManager];
|
||||||
_blockedPhoneNumberSet = [NSSet setWithArray:[_blockingManager blockedPhoneNumbers]];
|
_blockedPhoneNumberSet = [NSSet setWithArray:[_blockingManager blockedPhoneNumbers]];
|
||||||
_threadModelCache = [NSCache new];
|
_threadViewModelCache = [NSCache new];
|
||||||
|
|
||||||
// Ensure ExperienceUpgradeFinder has been initialized.
|
// Ensure ExperienceUpgradeFinder has been initialized.
|
||||||
[ExperienceUpgradeFinder sharedManager];
|
[ExperienceUpgradeFinder sharedManager];
|
||||||
|
@ -476,7 +476,7 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
||||||
- (void)reloadTableViewData
|
- (void)reloadTableViewData
|
||||||
{
|
{
|
||||||
// PERF: come up with a more nuanced cache clearing scheme
|
// PERF: come up with a more nuanced cache clearing scheme
|
||||||
[self.threadModelCache removeAllObjects];
|
[self.threadViewModelCache removeAllObjects];
|
||||||
[self.tableView reloadData];
|
[self.tableView reloadData];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -604,21 +604,21 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
||||||
return (NSInteger)[self.threadMappings numberOfItemsInSection:(NSUInteger)section];
|
return (NSInteger)[self.threadMappings numberOfItemsInSection:(NSUInteger)section];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (ThreadModel *)threadModelForIndexPath:(NSIndexPath *)indexPath
|
- (ThreadViewModel *)threadViewModelForIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
TSThread *threadRecord = [self threadForIndexPath:indexPath];
|
TSThread *threadRecord = [self threadForIndexPath:indexPath];
|
||||||
|
|
||||||
ThreadModel *_Nullable cachedThreadModel = [self.threadModelCache objectForKey:threadRecord.uniqueId];
|
ThreadViewModel *_Nullable cachedThreadViewModel = [self.threadViewModelCache objectForKey:threadRecord.uniqueId];
|
||||||
if (cachedThreadModel) {
|
if (cachedThreadViewModel) {
|
||||||
return cachedThreadModel;
|
return cachedThreadViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
__block ThreadModel *_Nullable newThreadModel;
|
__block ThreadViewModel *_Nullable newThreadViewModel;
|
||||||
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *_Nonnull transaction) {
|
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *_Nonnull transaction) {
|
||||||
newThreadModel = [[ThreadModel alloc] initWithThread:threadRecord transaction:transaction];
|
newThreadViewModel = [[ThreadViewModel alloc] initWithThread:threadRecord transaction:transaction];
|
||||||
}];
|
}];
|
||||||
[self.threadModelCache setObject:newThreadModel forKey:threadRecord.uniqueId];
|
[self.threadViewModelCache setObject:newThreadViewModel forKey:threadRecord.uniqueId];
|
||||||
return newThreadModel;
|
return newThreadViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||||
|
@ -626,7 +626,7 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
||||||
HomeViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:HomeViewCell.cellReuseIdentifier];
|
HomeViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:HomeViewCell.cellReuseIdentifier];
|
||||||
OWSAssert(cell);
|
OWSAssert(cell);
|
||||||
|
|
||||||
ThreadModel *thread = [self threadModelForIndexPath:indexPath];
|
ThreadViewModel *thread = [self threadViewModelForIndexPath:indexPath];
|
||||||
[cell configureWithThread:thread
|
[cell configureWithThread:thread
|
||||||
contactsManager:self.contactsManager
|
contactsManager:self.contactsManager
|
||||||
blockedPhoneNumberSet:self.blockedPhoneNumberSet];
|
blockedPhoneNumberSet:self.blockedPhoneNumberSet];
|
||||||
|
@ -1041,7 +1041,7 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
||||||
for (YapDatabaseViewRowChange *rowChange in rowChanges) {
|
for (YapDatabaseViewRowChange *rowChange in rowChanges) {
|
||||||
NSString *key = rowChange.collectionKey.key;
|
NSString *key = rowChange.collectionKey.key;
|
||||||
OWSAssert(key);
|
OWSAssert(key);
|
||||||
[self.threadModelCache removeObjectForKey:key];
|
[self.threadViewModelCache removeObjectForKey:key];
|
||||||
|
|
||||||
switch (rowChange.type) {
|
switch (rowChange.type) {
|
||||||
case YapDatabaseViewChangeDelete: {
|
case YapDatabaseViewChangeDelete: {
|
||||||
|
|
Loading…
Reference in a new issue