mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
1fb1b5bbe2
verify `description` isn't used elsewhere (notifications? conversation view?) Probably want to remove overzealous asserts for now, but would be good to work towards leaving them enabled. // FREEBIE
70 lines
2.2 KiB
Objective-C
70 lines
2.2 KiB
Objective-C
//
|
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
|
//
|
|
|
|
#import "TSYapDatabaseObject.h"
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
@class TSThread;
|
|
|
|
typedef NS_ENUM(NSInteger, OWSInteractionType) {
|
|
OWSInteractionType_Unknown,
|
|
OWSInteractionType_IncomingMessage,
|
|
OWSInteractionType_OutgoingMessage,
|
|
OWSInteractionType_Error,
|
|
OWSInteractionType_Call,
|
|
OWSInteractionType_Info,
|
|
OWSInteractionType_UnreadIndicator,
|
|
OWSInteractionType_Offer,
|
|
};
|
|
|
|
@protocol OWSPreviewText
|
|
|
|
- (NSString *)previewTextWithTransaction:(YapDatabaseReadTransaction *)transaction;
|
|
|
|
@end
|
|
|
|
@interface TSInteraction : TSYapDatabaseObject
|
|
|
|
- (instancetype)initInteractionWithTimestamp:(uint64_t)timestamp inThread:(TSThread *)thread;
|
|
|
|
@property (nonatomic, readonly) NSString *uniqueThreadId;
|
|
@property (nonatomic, readonly) TSThread *thread;
|
|
@property (nonatomic, readonly) uint64_t timestamp;
|
|
|
|
- (OWSInteractionType)interactionType;
|
|
|
|
- (TSThread *)threadWithTransaction:(YapDatabaseReadTransaction *)transaction;
|
|
|
|
/**
|
|
* When an interaction is updated, it often affects the UI for it's containing thread. Touching it's thread will notify
|
|
* any observers so they can redraw any related UI.
|
|
*/
|
|
- (void)touchThreadWithTransaction:(YapDatabaseReadWriteTransaction *)transaction;
|
|
|
|
#pragma mark Utility Method
|
|
|
|
+ (NSArray<TSInteraction *> *)interactionsWithTimestamp:(uint64_t)timestamp
|
|
ofClass:(Class)clazz
|
|
withTransaction:(YapDatabaseReadTransaction *)transaction;
|
|
|
|
+ (NSArray<TSInteraction *> *)interactionsWithTimestamp:(uint64_t)timestamp
|
|
filter:(BOOL (^_Nonnull)(TSInteraction *))filter
|
|
withTransaction:(YapDatabaseReadTransaction *)transaction;
|
|
|
|
- (NSDate *)dateForSorting;
|
|
- (uint64_t)timestampForSorting;
|
|
- (NSComparisonResult)compareForSorting:(TSInteraction *)other;
|
|
|
|
// "Dynamic" interactions are not messages or static events (like
|
|
// info messages, error messages, etc.). They are interactions
|
|
// created, updated and deleted by the views.
|
|
//
|
|
// These include block offers, "add to contact" offers,
|
|
// unseen message indicators, etc.
|
|
- (BOOL)isDynamicInteraction;
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|