Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes an issue that causing our previews to cancel loading. #12303

Merged
merged 3 commits into from
Aug 20, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions WordPress/Classes/ViewRelated/Post/PostPreviewViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ - (void)viewDidAppear:(BOOL)animated
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[self stopLoading];
shiki marked this conversation as resolved.
Show resolved Hide resolved
[self stopWaitingForConnectionRestored];
}

Expand All @@ -112,21 +111,22 @@ - (void)setupWebView
[self.view addSubview:self.webView];
}

#pragma mark - Loading
#pragma mark - Loading Animations

- (void)startLoading
- (void)startLoadAnimation
{
[self.navigationItem setLeftBarButtonItem:[self statusButtonItem] animated:YES];
self.navigationItem.title = nil;
}

- (void)stopLoading
- (void)stopLoadAnimation
shiki marked this conversation as resolved.
Show resolved Hide resolved
{
self.navigationItem.leftBarButtonItem = self.navigationItem.backBarButtonItem;
self.navigationItem.title = NSLocalizedString(@"Preview", @"Post Editor / Preview screen title.");
[self.webView stopLoading];
}

#pragma mark - Reachability

- (void)reloadWhenConnectionRestored
{
__weak __typeof(self) weakSelf = self;
Expand Down Expand Up @@ -154,7 +154,7 @@ - (void)refreshWebView
- (void)webViewDidFinishLoad:(UIWebView *)awebView
{
DDLogMethod();
[self stopLoading];
diegoreymendez marked this conversation as resolved.
Show resolved Hide resolved
[self stopLoadAnimation];
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
Expand All @@ -179,7 +179,8 @@ - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
return;
}

[self stopLoading];
[self stopLoadAnimation];

[self.generator previewRequestFailedWithReason:[NSString stringWithFormat:@"Generic web view error Error. Error code: %d, Error domain: %@", error.code, error.domain]];
}

Expand Down Expand Up @@ -214,6 +215,7 @@ - (BOOL)webView:(UIWebView *)awebView
if (navigationType == UIWebViewNavigationTypeFormSubmitted) {
return NO;
}

return YES;
}

Expand All @@ -225,7 +227,7 @@ - (void)preview:(PostPreviewGenerator *)generator loadHTML:(NSString *)html {
}

- (void)preview:(PostPreviewGenerator *)generator attemptRequest:(NSURLRequest *)request {
[self startLoading];
[self startLoadAnimation];
[self.webView loadRequest:request];
[self.noResultsViewController removeFromView];
}
Expand Down