Implement loadRequest method on SUWebView

This commit is contained in:
Zorg committed 2021-01-04 16:12:58 -08:00
1 parent dfff98d19e
commit 6283992215
4 files changed
+26 -1

No files matched your search

+6
View File
@@ -78,6 +78,12 @@
[[self.webView mainFrame] loadData:data MIMEType:MIMEType textEncodingName:textEncodingName baseURL:baseURL];
}
- (void)loadRequest:(NSURLRequest *)urlRequest completionHandler:(void (^)(NSError * _Nullable))completionHandler
{
self.completionHandler = [completionHandler copy];
[[self.webView mainFrame] loadRequest:urlRequest];
}
- (void)stopLoading
{
self.completionHandler = nil;
+7 -1
View File
@@ -159,7 +159,13 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
// If there's a release notes URL, load it; otherwise, just stick the contents of the description into the web view.
if ([self.updateItem releaseNotesURL])
{
//[[self.releaseNotesView mainFrame] loadRequest:[NSURLRequest requestWithURL:[self.updateItem releaseNotesURL] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30]];
__weak __typeof__(self) weakSelf = self;
[self.webView loadRequest:[NSURLRequest requestWithURL:[self.updateItem releaseNotesURL] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30] completionHandler:^(NSError * _Nullable error) {
if (error != nil) {
SULog(SULogLevelError, @"Failed to load URL request from web view: %@", error);
}
[weakSelf stopReleaseNotesSpinner];
}];
}
else
{
+11
View File
@@ -135,6 +135,17 @@ static WKUserScript *_userScriptWithInjectedStyleSource(NSString *styleSource)
#pragma clang diagnostic pop
}
- (void)loadRequest:(NSURLRequest *)urlRequest completionHandler:(void (^)(NSError * _Nullable))completionHandler
{
self.completionHandler = [completionHandler copy];
// Remove when minimum system requirement is 10.10+
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability"
self.currentNavigation = [self.webView loadRequest:urlRequest];
#pragma clang diagnostic pop
}
- (void)setDrawsBackground:(BOOL)drawsBackground
{
if (self.drawsWebViewBackground != drawsBackground) {
+2
View File
@@ -20,6 +20,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)loadData:(NSData *)data MIMEType:(NSString *)MIMEType textEncodingName:(NSString *)textEncodingName baseURL:(NSURL *)baseURL completionHandler:(void (^)(NSError * _Nullable))completionHandler;
- (void)loadRequest:(NSURLRequest *)urlRequest completionHandler:(void (^)(NSError * _Nullable))completionHandler;
- (void)stopLoading;
- (void)setDrawsBackground:(BOOL)drawsBackground;