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 #359 from tabuchid/new-thread
Browse files Browse the repository at this point in the history
Force New Feedback thread
  • Loading branch information
Benjamin Scholtysik (Reimold) authored Nov 30, 2016
2 parents 3b750b4 + 8c39868 commit ffdfac2
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
1 change: 0 additions & 1 deletion Classes/BITFeedbackManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ typedef NS_ENUM(NSInteger, BITFeedbackObservationMode) {
*/
@property (nonatomic, readwrite) BITFeedbackObservationMode feedbackObservationMode;


/**
Prefill feedback compose message user interface with the items given.
Expand Down
29 changes: 23 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 @@ -450,7 +450,7 @@ - (void)loadMessages {

if ([unarchiver containsValueForKey:kBITFeedbackUserDataAsked])
_didAskUserData = YES;

if ([unarchiver containsValueForKey:kBITFeedbackToken]) {
self.token = [unarchiver decodeObjectForKey:kBITFeedbackToken];
[self addStringValueToKeychain:self.token forKey:kBITFeedbackToken];
Expand All @@ -467,7 +467,11 @@ - (void)loadMessages {
self.token = nil;
}
}


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

if ([unarchiver containsValueForKey:kBITFeedbackDateOfLastCheck])
self.lastCheck = [unarchiver decodeObjectForKey:kBITFeedbackDateOfLastCheck];

Expand Down Expand Up @@ -657,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 @@ -729,9 +742,13 @@ - (void)updateMessageListFromResponse:(NSDictionary *)jsonDictionary {
NSString *token = [jsonDictionary objectForKey:@"token"];
NSDictionary *feedbackObject = [jsonDictionary objectForKey:@"feedback"];
if (feedback && token && feedbackObject) {
// update the thread token, which is not available until the 1st message was successfully sent
self.token = token;

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;
}

self.lastCheck = [NSDate date];

// add all new messages
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 ffdfac2

Please sign in to comment.