From f6e00bb53a0eb6a20a4db84deb6accf39e598018 Mon Sep 17 00:00:00 2001 From: Nikita Semenov Date: Mon, 30 Jan 2023 11:42:06 +0300 Subject: [PATCH] fix: code review notes --- CHANGELOG.md | 2 +- TIWebView/Sources/ErrorHandler/WebViewErrorHandler.swift | 4 ++-- .../Sources/NavigationHandler/BaseWebViewNavigator.swift | 8 ++++---- .../Sources/NavigationHandler/WebViewNavigator.swift | 6 +++--- .../Sources/Views/ViewModels/DefaultWebViewModel.swift | 2 +- TIWebView/Sources/Views/ViewModels/WebViewModel.swift | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7df67573..01468992 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ### 1.32.0 -- **Added**: `BaseInitializableWebView`with navigation and error handling api. +- **Added**: `BaseInitializableWebView` with navigation and error handling api. ### 1.31.0 diff --git a/TIWebView/Sources/ErrorHandler/WebViewErrorHandler.swift b/TIWebView/Sources/ErrorHandler/WebViewErrorHandler.swift index 97ace4df..7a58b748 100644 --- a/TIWebView/Sources/ErrorHandler/WebViewErrorHandler.swift +++ b/TIWebView/Sources/ErrorHandler/WebViewErrorHandler.swift @@ -21,11 +21,11 @@ // public protocol WebViewErrorHandler { - func didRecievedError(_ error: WebViewError) + func didReceiveError(_ error: WebViewError) } public extension WebViewErrorHandler { - func didRecievedError(_ error: WebViewError) { + func didReceiveError(_ error: WebViewError) { // override in subclasses } } diff --git a/TIWebView/Sources/NavigationHandler/BaseWebViewNavigator.swift b/TIWebView/Sources/NavigationHandler/BaseWebViewNavigator.swift index 57095021..b7eb828a 100644 --- a/TIWebView/Sources/NavigationHandler/BaseWebViewNavigator.swift +++ b/TIWebView/Sources/NavigationHandler/BaseWebViewNavigator.swift @@ -22,13 +22,13 @@ open class BaseWebViewNavigator: WebViewNavigator { - public var navigationMap: [NavigationPolicy] + public var navigationPolicyMap: [NavigationPolicy] - public init(navigationMap: [NavigationPolicy]) { - self.navigationMap = navigationMap + public init(navigationPolicyMap: [NavigationPolicy]) { + self.navigationPolicyMap = navigationPolicyMap } public convenience init() { - self.init(navigationMap: []) + self.init(navigationPolicyMap: []) } } diff --git a/TIWebView/Sources/NavigationHandler/WebViewNavigator.swift b/TIWebView/Sources/NavigationHandler/WebViewNavigator.swift index 303f7782..8fd653ce 100644 --- a/TIWebView/Sources/NavigationHandler/WebViewNavigator.swift +++ b/TIWebView/Sources/NavigationHandler/WebViewNavigator.swift @@ -24,18 +24,18 @@ import Foundation import enum WebKit.WKNavigationActionPolicy public protocol WebViewNavigator { - var navigationMap: [NavigationPolicy] { get set } + var navigationPolicyMap: [NavigationPolicy] { get set } func shouldNavigate(to url: URL) -> WKNavigationActionPolicy } public extension WebViewNavigator { func shouldNavigate(to url: URL) -> WKNavigationActionPolicy { - guard !navigationMap.isEmpty else { + guard !navigationPolicyMap.isEmpty else { return .cancel } - let allowPolicy = navigationMap.filter { $0.policy(for: url) == .allow } + let allowPolicy = navigationPolicyMap.filter { $0.policy(for: url) == .allow } return allowPolicy.isEmpty ? .cancel : .allow } } diff --git a/TIWebView/Sources/Views/ViewModels/DefaultWebViewModel.swift b/TIWebView/Sources/Views/ViewModels/DefaultWebViewModel.swift index b772bbae..6caaf1de 100644 --- a/TIWebView/Sources/Views/ViewModels/DefaultWebViewModel.swift +++ b/TIWebView/Sources/Views/ViewModels/DefaultWebViewModel.swift @@ -48,7 +48,7 @@ open class DefaultWebViewModel: NSObject, WebViewModel { if message.name == WebViewErrorConstants.errorMessageName, let error = parseError(message) { - errorHandler.didRecievedError(error) + errorHandler.didReceiveError(error) } } diff --git a/TIWebView/Sources/Views/ViewModels/WebViewModel.swift b/TIWebView/Sources/Views/ViewModels/WebViewModel.swift index 9cd4336e..409d21b4 100644 --- a/TIWebView/Sources/Views/ViewModels/WebViewModel.swift +++ b/TIWebView/Sources/Views/ViewModels/WebViewModel.swift @@ -44,6 +44,6 @@ public extension WebViewModel { func handleError(_ error: Error, url: URL?) { let errorModel = WebViewLoadingError(sourceURL: url, innerError: error) - errorHandler.didRecievedError(errorModel) + errorHandler.didReceiveError(errorModel) } }