From 15607295eb547d8d9a13b57622c8101bd61c3fed Mon Sep 17 00:00:00 2001 From: "Benjamin Scholtysik (Reimold)" Date: Tue, 29 Nov 2016 17:16:19 -0800 Subject: [PATCH] Use FeedbackManagerDelegate to add forse a new feedback thread. --- Classes/BITFeedbackManager.h | 11 ----------- Classes/BITFeedbackManager.m | 17 ++++++++++++----- Classes/BITFeedbackManagerDelegate.h | 10 ++++++++++ 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/Classes/BITFeedbackManager.h b/Classes/BITFeedbackManager.h index ed6841a9..3ef85c45 100644 --- a/Classes/BITFeedbackManager.h +++ b/Classes/BITFeedbackManager.h @@ -225,17 +225,6 @@ typedef NS_ENUM(NSInteger, BITFeedbackObservationMode) { */ @property (nonatomic, readwrite) BITFeedbackObservationMode feedbackObservationMode; -/** - Indicates if a new thread should be created for each new feedback message - - Setting thos to `YES` will force a new thread whenever a new message is sent as - opposed to the default resume thread behaviour. - - Default is `NO` - */ -@property (nonatomic, readwrite) BOOL forceNewThread; - - /** Prefill feedback compose message user interface with the items given. diff --git a/Classes/BITFeedbackManager.m b/Classes/BITFeedbackManager.m index a2cf81af..23541bfc 100644 --- a/Classes/BITFeedbackManager.m +++ b/Classes/BITFeedbackManager.m @@ -77,7 +77,6 @@ @implementation BITFeedbackManager { BOOL _incomingMessagesAlertShowing; BOOL _didEnterBackgroundState; BOOL _networkRequestInProgress; - BOOL _forceNewThread; BITFeedbackObservationMode _observationMode; } @@ -94,7 +93,6 @@ - (instancetype)init { _requireUserEmail = BITFeedbackUserDataElementOptional; _showAlertOnIncomingMessages = YES; _showFirstRequiredPresentationModal = YES; - _forceNewThread = NO; _disableFeedbackManager = NO; _networkRequestInProgress = NO; @@ -470,7 +468,7 @@ - (void)loadMessages { } } - if (_forceNewThread) { + if ([self shouldForceNewThread]) { self.token = nil; } @@ -663,6 +661,15 @@ - (void)deleteAllMessages { [self saveMessages]; } +- (BOOL)shouldForceNewThread { + if (self.delegate && [self.delegate respondsToSelector:@selector(forceNewFeedbackThreadForFeedbackManager:)]) { + return [self.delegate forceNewFeedbackThreadForFeedbackManager:self]; + } + else { + return NO; + } +} + #pragma mark - User @@ -735,8 +742,8 @@ - (void)updateMessageListFromResponse:(NSDictionary *)jsonDictionary { NSString *token = [jsonDictionary objectForKey:@"token"]; NSDictionary *feedbackObject = [jsonDictionary objectForKey:@"feedback"]; if (feedback && token && feedbackObject) { - if (self.forceNewThread) { - self.token = nil; + if ([self shouldForceNewThread]) { + self.token = nil; } else { // update the thread token, which is not available until the 1st message was successfully sent self.token = token; diff --git a/Classes/BITFeedbackManagerDelegate.h b/Classes/BITFeedbackManagerDelegate.h index 64449694..029732a5 100644 --- a/Classes/BITFeedbackManagerDelegate.h +++ b/Classes/BITFeedbackManagerDelegate.h @@ -82,6 +82,16 @@ NS_ASSUME_NONNULL_BEGIN */ - (nullable NSArray *)preparedItemsForFeedbackManager:(BITFeedbackManager *)feedbackManager; +/** + * Indicates if a new thread should be created for each new feedback message + * + * Setting it to `YES` will force a new thread whenever a new message is sent as + * opposed to the default resume thread behaviour. + * + * @return A BOOL indicating if each feedback message should be sent as a new thread. + */ +- (BOOL)forceNewFeedbackThreadForFeedbackManager:(BITFeedbackManager *)feedbackManager; + @end NS_ASSUME_NONNULL_END