Skip to content

Commit

Permalink
Merge pull request #69 from dgattey/master
Browse files Browse the repository at this point in the history
Adds configuration for shouldContinueSearchingAfterEmptyResults
  • Loading branch information
jmkk authored Jun 2, 2018
2 parents 5552ae4 + f4ae351 commit d496aca
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Hakawai.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "Hakawai"
s.version = "5.1.4"
s.version = "5.1.5"
s.summary = "Hakawai aims to be a more powerful UITextView."
s.description = <<-DESC
Hakawai is a subclass of UITextView that exposes a number of convenience APIs, and supports further extension via 'plug-ins'. Hakawai ships with an easy-to-use, powerful, and customizable plug-in allowing users to create social media 'mentions'-style annotations.
Expand All @@ -20,7 +20,7 @@ Pod::Spec.new do |s|
s.license = { :type => "Apache License, Version 2.0", :file => "LICENSE" }
s.authors = "Austin Zheng"
s.platform = :ios, "7.0"
s.source = { :git => "https://github.com/linkedin/Hakawai.git", :tag => "5.1.4" }
s.source = { :git => "https://github.com/linkedin/Hakawai.git", :tag => "5.1.5" }
s.framework = "UIKit"
s.requires_arc = true
end
8 changes: 8 additions & 0 deletions Hakawai.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
11 changes: 7 additions & 4 deletions Hakawai/Mentions/HKWMentionsCreationStateMachine.m
Original file line number Diff line number Diff line change
Expand Up @@ -788,10 +788,12 @@ - (void)handleFinalizedQueryWithNoResults:(HKWMentionsCreationAction)previousAct
self.chooserState = HKWMentionsCreationChooserStateHidden;

// However, there are two conditions under which mentions creation should actually end completely:
// 1. The user's initial query turned up no results
// 1. The user's initial query turned up no results and we should not continue searching after empty results
// 2. There are no results because the last character the user typed was a whitespace or newline (whether or not
// the previous request resulted in results or not)
BOOL shouldStop = (self.resultsState == HKWMentionsCreationResultsStateAwaitingFirstResult
// the previous request resulted ifn results or not)
BOOL noResultsAndShouldStop = (!self.delegate.shouldContinueSearchingAfterEmptyResults
&& self.resultsState == HKWMentionsCreationResultsStateAwaitingFirstResult);
BOOL shouldStop = (noResultsAndShouldStop
|| previousAction == HKWMentionsCreationActionWhitespaceCharacterInserted);
if (shouldStop) {
[self.delegate cancelMentionFromStartingLocation:self.startingLocation];
Expand All @@ -801,7 +803,8 @@ - (void)handleFinalizedQueryWithNoResults:(HKWMentionsCreationAction)previousAct

// Advance the results state. The user could have been in one of two states formally: results existed, or there were
// no results but the user hadn't typed a whitespace character since results stopped coming back
NSAssert(self.resultsState == HKWMentionsCreationResultsStateCreatingMentionWithResults
NSAssert((self.delegate.shouldContinueSearchingAfterEmptyResults && self.resultsState == HKWMentionsCreationResultsStateAwaitingFirstResult)
|| self.resultsState == HKWMentionsCreationResultsStateCreatingMentionWithResults
|| self.resultsState == HKWMentionsCreationResultsStateNoResultsWithoutWhitespace,
@"Logic error in dataReturnedForResults:...; resultsState is inconsistent. Got %@, which is invalid.",
nameForResultsState(self.resultsState));
Expand Down
7 changes: 7 additions & 0 deletions Hakawai/Mentions/HKWMentionsPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,13 @@ typedef NS_ENUM(NSInteger, HKWMentionsPluginState) {
*/
@property (nonatomic) BOOL resumeMentionsCreationEnabled;

/*!
Whether or not we should continue searching for an explicit mention after we get back empty results. If this
is off, empty results will return the mentions creation state to \c HKWMentionsPluginStateQuiescent. If this is
on, empty results won't modify the mentions creation state.
*/
@property (nonatomic) BOOL shouldContinueSearchingAfterEmptyResults;


#pragma mark - Chooser UI Configuration

Expand Down
7 changes: 7 additions & 0 deletions Hakawai/Mentions/_HKWMentionsCreationStateMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
*/
@property (nonatomic, readonly) BOOL loadingCellSupported;

/*!
Whether or not we should continue searching for an explicit mention after we get back empty results. If this
is off, empty results will return the mentions creation state to \c HKWMentionsPluginStateQuiescent. If this is
on, empty results won't modify the mentions creation state.
*/
@property (nonatomic, readonly) BOOL shouldContinueSearchingAfterEmptyResults;

/*!
Request the bounds of the editor text view owning the delegate.
*/
Expand Down

0 comments on commit d496aca

Please sign in to comment.