Skip to content

Commit

Permalink
add _hasCompleted to prevent goForward from being called after naviga…
Browse files Browse the repository at this point in the history
…tion starts
  • Loading branch information
eschramm committed Jul 3, 2024
1 parent 7f9abbb commit 0502c46
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion ORK1Kit/ORK1Kit/Common/ORK1WebViewStepViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ @interface ORK1WebViewStepViewController ()
@implementation ORK1WebViewStepViewController {
NSString *_result;
NSString *_originalResult;
BOOL _hasCompleted;
}

#pragma mark Public Interface
Expand Down Expand Up @@ -214,9 +215,10 @@ - (void)userContentController:(WKUserContentController *)userContentController d
/// Returns YES if the view controller should stop processing any other messages. Assumes that `shouldProcessScriptMessages` is true.
/// - Parameter message: The message to process.
- (BOOL)processScriptMessage:(WKScriptMessage *)message {
if ([message.name isEqualToString:ResearchKitCompleteStepMessageName] && [message.body isKindOfClass:[NSString class]]) {
if ([message.name isEqualToString:ResearchKitCompleteStepMessageName] && [message.body isKindOfClass:[NSString class]] && !_hasCompleted) {
_result = (NSString *)message.body;
[self goForward];
_hasCompleted = YES;
return YES;
}

Expand Down
4 changes: 3 additions & 1 deletion ResearchKit/Common/ORKWebViewStepViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ @implementation ORKWebViewStepViewController {
NSString *_originalResult;
ORKNavigationContainerView *_navigationFooterView;
NSArray<NSLayoutConstraint *> *_constraints;
BOOL _hasCompleted;
}

#pragma mark Public Interface
Expand Down Expand Up @@ -316,9 +317,10 @@ - (void)userContentController:(WKUserContentController *)userContentController d
/// Returns YES if the view controller should stop processing any other messages. Assumes that `shouldProcessScriptMessages` is true.
/// - Parameter message: The message to process.
- (BOOL)processScriptMessage:(WKScriptMessage *)message {
if ([message.name isEqualToString:ResearchKitCompleteStepMessageName] && [message.body isKindOfClass:[NSString class]]) {
if ([message.name isEqualToString:ResearchKitCompleteStepMessageName] && [message.body isKindOfClass:[NSString class]] && !_hasCompleted) {
_result = (NSString *)message.body;
[self goForward];
_hasCompleted = YES;
return YES;
}

Expand Down

0 comments on commit 0502c46

Please sign in to comment.