session-ios/SessionMessagingKit/Threads/TSThread.h

119 lines
3.6 KiB
C
Raw Normal View History

2020-11-11 00:58:56 +01:00
//
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
2020-11-23 00:24:40 +01:00
#import <SessionUtilitiesKit/TSYapDatabaseObject.h>
2020-11-11 00:58:56 +01:00
NS_ASSUME_NONNULL_BEGIN
BOOL IsNoteToSelfEnabled(void);
@class OWSDisappearingMessagesConfiguration;
@class TSInteraction;
/**
* TSThread is the superclass of TSContactThread and TSGroupThread
*/
@interface TSThread : TSYapDatabaseObject
2021-05-05 01:53:18 +02:00
@property (nonatomic) BOOL shouldBeVisible;
2020-11-11 00:58:56 +01:00
@property (nonatomic, readonly) NSDate *creationDate;
@property (nonatomic, readonly) TSInteraction *lastInteraction;
2021-05-05 01:53:18 +02:00
@property (atomic, readonly) BOOL isMuted;
@property (atomic, readonly, nullable) NSDate *mutedUntilDate;
2020-11-11 00:58:56 +01:00
/**
* Whether the object is a group thread or not.
*
* @return YES if is a group thread, NO otherwise.
*/
- (BOOL)isGroupThread;
/**
* Returns the name of the thread.
*
* @return The name of the thread.
*/
- (NSString *)name;
/**
* @returns recipientId for each recipient in the thread
*/
@property (nonatomic, readonly) NSArray<NSString *> *recipientIdentifiers;
- (BOOL)isNoteToSelf;
#pragma mark Interactions
2021-05-05 05:49:24 +02:00
- (void)enumerateInteractionsWithTransaction:(YapDatabaseReadTransaction *)transaction usingBlock:(void (^)(TSInteraction *interaction, BOOL *stop))block;
2020-11-11 00:58:56 +01:00
- (void)enumerateInteractionsUsingBlock:(void (^)(TSInteraction *interaction))block;
/**
* @return The number of interactions in this thread.
*/
- (NSUInteger)numberOfInteractions;
- (NSUInteger)unreadMessageCountWithTransaction:(YapDatabaseReadTransaction *)transaction
NS_SWIFT_NAME(unreadMessageCount(transaction:));
- (void)markAllAsReadWithTransaction:(YapDatabaseReadWriteTransaction *)transaction;
/**
* Returns the string that will be displayed typically in a conversations view as a preview of the last message
2021-05-05 01:53:18 +02:00
* received in this thread.
2020-11-11 00:58:56 +01:00
*
* @return Thread preview string.
*/
- (NSString *)lastMessageTextWithTransaction:(YapDatabaseReadTransaction *)transaction
NS_SWIFT_NAME(lastMessageText(transaction:));
- (nullable TSInteraction *)lastInteractionForInboxWithTransaction:(YapDatabaseReadTransaction *)transaction
NS_SWIFT_NAME(lastInteractionForInbox(transaction:));
/**
* Updates the thread's caches of the latest interaction.
*
* @param lastMessage Latest Interaction to take into consideration.
* @param transaction Database transaction.
*/
- (void)updateWithLastMessage:(TSInteraction *)lastMessage transaction:(YapDatabaseReadWriteTransaction *)transaction;
- (void)removeAllThreadInteractionsWithTransaction:(YapDatabaseReadWriteTransaction *)transaction;
- (TSInteraction *)getLastInteractionWithTransaction:(YapDatabaseReadTransaction *)transaction;
#pragma mark Disappearing Messages
- (OWSDisappearingMessagesConfiguration *)disappearingMessagesConfigurationWithTransaction:
(YapDatabaseReadTransaction *)transaction;
2021-05-05 01:53:18 +02:00
2020-11-11 00:58:56 +01:00
- (uint32_t)disappearingMessagesDurationWithTransaction:(YapDatabaseReadTransaction *)transaction;
#pragma mark Drafts
/**
* Returns the last known draft for that thread. Always returns a string. Empty string if nil.
*
* @param transaction Database transaction.
*
* @return Last known draft for that thread.
*/
- (NSString *)currentDraftWithTransaction:(YapDatabaseReadTransaction *)transaction;
/**
* Sets the draft of a thread. Typically called when leaving a conversation view.
*
* @param draftString Draft string to be saved.
* @param transaction Database transaction.
*/
- (void)setDraft:(NSString *)draftString transaction:(YapDatabaseReadWriteTransaction *)transaction;
2021-05-05 01:53:18 +02:00
#pragma mark Muting
2020-11-11 00:58:56 +01:00
2021-07-13 08:09:28 +02:00
- (void)updateWithMutedUntilDate:(NSDate * _Nullable)mutedUntilDate transaction:(YapDatabaseReadWriteTransaction *)transaction;
2020-11-11 00:58:56 +01:00
@end
NS_ASSUME_NONNULL_END