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

Commit

Permalink
Merge pull request #1 from TroubleMakerBen/new-thread
Browse files Browse the repository at this point in the history
New thread
  • Loading branch information
tabuchid authored Nov 30, 2016
2 parents e67bfb9 + b5cc5dc commit 8c39868
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 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
19 changes: 13 additions & 6 deletions Classes/BITFeedbackManager.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Author: Andreas Linde <mail@andreaslinde.de>
*
* Copyright (c) 2012-2014 HockeyApp, Bit Stadium GmbH.
* Copyright (c) 2012-2016 HockeyApp, Bit Stadium GmbH.
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
Expand Down 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
14 changes: 12 additions & 2 deletions Classes/BITFeedbackManagerDelegate.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Author: Stephan Diederich
* Authors: Stephan Diederich, Benjamin Scholtysik
*
* Copyright (c) 2013-2014 HockeyApp, Bit Stadium GmbH.
* Copyright (c) 2013-2016 HockeyApp, Bit Stadium GmbH.
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
Expand Down 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 8c39868

Please sign in to comment.