Skip to content
This repository has been archived by the owner on Feb 19, 2020. It is now read-only.

Commit

Permalink
Use FeedbackManagerDelegate to add forse a new feedback thread.
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Scholtysik (Reimold) committed Nov 30, 2016
1 parent e67bfb9 commit 1560729
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
11 changes: 0 additions & 11 deletions Classes/BITFeedbackManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 12 additions & 5 deletions Classes/BITFeedbackManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ @implementation BITFeedbackManager {
BOOL _incomingMessagesAlertShowing;
BOOL _didEnterBackgroundState;
BOOL _networkRequestInProgress;
BOOL _forceNewThread;

BITFeedbackObservationMode _observationMode;
}
Expand All @@ -94,7 +93,6 @@ - (instancetype)init {
_requireUserEmail = BITFeedbackUserDataElementOptional;
_showAlertOnIncomingMessages = YES;
_showFirstRequiredPresentationModal = YES;
_forceNewThread = NO;

_disableFeedbackManager = NO;
_networkRequestInProgress = NO;
Expand Down Expand Up @@ -470,7 +468,7 @@ - (void)loadMessages {
}
}

if (_forceNewThread) {
if ([self shouldForceNewThread]) {
self.token = nil;
}

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions Classes/BITFeedbackManagerDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 1560729

Please sign in to comment.