Skip to content

Commit

Permalink
Updated Action and State for native error pages
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharC95 committed Oct 24, 2024
1 parent e213824 commit 2cacdf5
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 110 deletions.
16 changes: 8 additions & 8 deletions firefox-ios/Client.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,8 @@
631A369F2CC0A4FE0044DFEB /* NativeErrorPageMiddleware.swift in Sources */ = {isa = PBXBuildFile; fileRef = 631A369E2CC0A4FE0044DFEB /* NativeErrorPageMiddleware.swift */; };
631A36A32CC0B2470044DFEB /* NativeErrorPageHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 631A36A22CC0B2470044DFEB /* NativeErrorPageHelper.swift */; };
63306D3921103EAE00F25400 /* LegacySavedTab.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63306D3821103EAE00F25400 /* LegacySavedTab.swift */; };
6396AD152CC2C0360060D0B7 /* NativeErrorPageState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6396AD142CC2C0360060D0B7 /* NativeErrorPageState.swift */; };
6396AD172CC2C0430060D0B7 /* NativeErrorPageAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6396AD162CC2C0430060D0B7 /* NativeErrorPageAction.swift */; };
63B213282CCA796D00A466DB /* NativeErrorPageAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63B213272CCA796D00A466DB /* NativeErrorPageAction.swift */; };
63B2132A2CCA797400A466DB /* NativeErrorPageState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63B213292CCA797400A466DB /* NativeErrorPageState.swift */; };
63F7A9AA2C7529ED005846F5 /* NativeErrorPageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63F7A9A92C7529ED005846F5 /* NativeErrorPageModel.swift */; };
63F7A9AC2C752BB0005846F5 /* NativeErrorPageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63F7A9AB2C752BB0005846F5 /* NativeErrorPageViewController.swift */; };
6669B5E2211418A200CA117B /* WebsiteDataSearchResultsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6669B5E1211418A200CA117B /* WebsiteDataSearchResultsViewController.swift */; };
Expand Down Expand Up @@ -6508,9 +6508,9 @@
631A36A22CC0B2470044DFEB /* NativeErrorPageHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NativeErrorPageHelper.swift; sourceTree = "<group>"; };
63306D3821103EAE00F25400 /* LegacySavedTab.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LegacySavedTab.swift; sourceTree = "<group>"; };
634148899F41CAA3BCF71E8B /* or */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = or; path = or.lproj/Localizable.strings; sourceTree = "<group>"; };
6396AD142CC2C0360060D0B7 /* NativeErrorPageState.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NativeErrorPageState.swift; path = "../../../../../../../Desktop/NativeErrorPage/HandlerChangesTo be Merged/NativeErrorPageState.swift"; sourceTree = "<group>"; };
6396AD162CC2C0430060D0B7 /* NativeErrorPageAction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NativeErrorPageAction.swift; path = "../../../../../../../Desktop/NativeErrorPage/HandlerChangesTo be Merged/NativeErrorPageAction.swift"; sourceTree = "<group>"; };
63B04BE882C41584580E0E59 /* fa */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fa; path = "fa.lproj/Default Browser.strings"; sourceTree = "<group>"; };
63B213272CCA796D00A466DB /* NativeErrorPageAction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NativeErrorPageAction.swift; sourceTree = "<group>"; };
63B213292CCA797400A466DB /* NativeErrorPageState.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NativeErrorPageState.swift; sourceTree = "<group>"; };
63F7A9A92C7529ED005846F5 /* NativeErrorPageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NativeErrorPageModel.swift; sourceTree = "<group>"; };
63F7A9AB2C752BB0005846F5 /* NativeErrorPageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NativeErrorPageViewController.swift; sourceTree = "<group>"; };
63FE433D87018CDDFCF592E3 /* sk */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sk; path = sk.lproj/ErrorPages.strings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -10533,8 +10533,8 @@
isa = PBXGroup;
children = (
63F7A9A92C7529ED005846F5 /* NativeErrorPageModel.swift */,
6396AD162CC2C0430060D0B7 /* NativeErrorPageAction.swift */,
6396AD142CC2C0360060D0B7 /* NativeErrorPageState.swift */,
63B213292CCA797400A466DB /* NativeErrorPageState.swift */,
63B213272CCA796D00A466DB /* NativeErrorPageAction.swift */,
631A369E2CC0A4FE0044DFEB /* NativeErrorPageMiddleware.swift */,
631A36A22CC0B2470044DFEB /* NativeErrorPageHelper.swift */,
63F7A9AB2C752BB0005846F5 /* NativeErrorPageViewController.swift */,
Expand Down Expand Up @@ -15856,6 +15856,7 @@
0E77DF0F2CB8220000B80BA1 /* GeneratedPasswordStorage.swift in Sources */,
219A0FDB2ACCCFFC009A6D1A /* InactiveTabsSectionManager.swift in Sources */,
B2981F8A2B71AD7A00132C1B /* AutofillAccessoryViewButtonItem.swift in Sources */,
63B213282CCA796D00A466DB /* NativeErrorPageAction.swift in Sources */,
211F00AC27F4D918001D9189 /* HistoryPanel+Search.swift in Sources */,
8AF347E02CADD1C300624036 /* HomepageAction.swift in Sources */,
96EB6C3827D821B800A9D159 /* HistoryPanelViewModel.swift in Sources */,
Expand Down Expand Up @@ -16152,7 +16153,6 @@
8A454D362CB86993009436D9 /* PocketItem.swift in Sources */,
1D7B78992ADF328E0011E9F2 /* AppEvent.swift in Sources */,
43F7952525795F69005AEE40 /* SearchTelemetry.swift in Sources */,
6396AD152CC2C0360060D0B7 /* NativeErrorPageState.swift in Sources */,
E65075541E37F6FC006961AC /* LegacyDynamicFontHelper.swift in Sources */,
8ADAE4242A33A126007BF926 /* StudiesToggleSetting.swift in Sources */,
8A46F5AC2C9E4389005B6422 /* RemoteDataType.swift in Sources */,
Expand Down Expand Up @@ -16210,6 +16210,7 @@
8C4B0F5D2C076B12008B3E74 /* UpdatableAddressFields+Decodable.swift in Sources */,
C8B0F5F6283B7CCE007AE65D /* PocketStory.swift in Sources */,
C81AC6B626160091007800C5 /* LegacyTabTrayViewModel.swift in Sources */,
63B2132A2CCA797400A466DB /* NativeErrorPageState.swift in Sources */,
8ADAE4222A33A113007BF926 /* SendAnonymousUsageDataSetting.swift in Sources */,
E170CA542B72C07A0082EFC5 /* FakespotActionFooterView.swift in Sources */,
C8EDDBF229DF1159003A4C07 /* URLScanner.swift in Sources */,
Expand Down Expand Up @@ -16380,7 +16381,6 @@
0A76936B2C82018700103A6D /* TrackingProtectionBlockedTrackersView.swift in Sources */,
E1463D022981DA190074E16E /* NotificationManager.swift in Sources */,
219A0FD92ACC8C0F009A6D1A /* InactiveTabsFooterView.swift in Sources */,
6396AD172CC2C0430060D0B7 /* NativeErrorPageAction.swift in Sources */,
884CA7492344A301002E4711 /* TextContentDetector.swift in Sources */,
C8656D77270F858900E199EA /* TabsSettingsViewControler.swift in Sources */,
8A9F0B5627C595F300FE09AE /* ImageIdentifiers.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,24 @@ import Redux
import Common

final class NativeErrorPageAction: Action {
let nativeErrorPageModel: ErrorPageModel?
init(nativeErrorPageModel: ErrorPageModel, windowUUID: WindowUUID, actionType: any ActionType) {
self.nativeErrorPageModel = nativeErrorPageModel
let networkError: NSError?
let nativePageErrorModel: ErrorPageModel?
init(
networkError: NSError? = nil,
nativePageErrorModel: ErrorPageModel? = nil,
windowUUID: WindowUUID,
actionType: any ActionType
) {
self.networkError = networkError
self.nativePageErrorModel = nativePageErrorModel
super.init(windowUUID: windowUUID, actionType: actionType)
}
}

enum NativeErrorPageActionType: ActionType {
case reload
// case goBack
// case tapAdvanced
// case proceedToURL
// case learMore
// case viewCertificate
case receivedError
}

enum NativeErrorPageMiddlewareActionType: ActionType {
case initialize
}
120 changes: 27 additions & 93 deletions firefox-ios/Client/Frontend/NativeErrorPage/NativeErrorPageState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,128 +8,62 @@ import Common

struct NativeErrorPageState: ScreenState, Equatable {
var windowUUID: WindowUUID
var shouldReload: Bool
// var showProceedToURL: Bool
// var showLearnMore: Bool
// var showCertificate: Bool
// var shouldGoBack: Bool
var model: ErrorPageModel?
var title: String?
var description: String?

init(appState: AppState, uuid: WindowUUID) {
guard let nativeErrorPageState = store.state.screenState(
NativeErrorPageState.self,
for: .nativeErrorPage,
window: uuid
) else {
self.init(windowUUID: uuid, model: nil)
self.init(windowUUID: uuid)
return
}

self.init(
windowUUID: nativeErrorPageState.windowUUID,
shouldReload: nativeErrorPageState.shouldReload,
// showProceedToURL: nativeErrorPageState.showProceedToURL,
// showLearnMore: nativeErrorPageState.showLearnMore,
// showCertificate: nativeErrorPageState.showCertificate,
// shouldGoBack: nativeErrorPageState.shouldGoBack
model: nativeErrorPageState.model
title: nativeErrorPageState.title,
description: nativeErrorPageState.description
)
}

init(
windowUUID: WindowUUID,
model: ErrorPageModel? = nil
) {
self.init(
windowUUID: windowUUID,
shouldReload: false,
// showProceedToURL: false,
// showLearnMore: false,
// showCertificate: false,
// shouldGoBack: false
model: model
)
}

private init(
windowUUID: WindowUUID,
shouldReload: Bool,
// showProceedToURL: Bool,
// showLearnMore: Bool,
// showCertificate: Bool,
// shouldGoBack: Bool
model: ErrorPageModel?
title: String? = nil,
description: String? = nil
) {
self.windowUUID = windowUUID
self.shouldReload = shouldReload
// self.showProceedToURL = showProceedToURL
// self.showLearnMore = showLearnMore
// self.showCertificate = showCertificate
// self.shouldGoBack = shouldGoBack
self.model = model
self.title = title
self.description = description
}

static let reducer: Reducer<Self> = { state, action in
guard action.windowUUID == .unavailable || action.windowUUID == state.windowUUID else { return state }

print(action.actionType)
guard action.windowUUID == .unavailable || action.windowUUID == state.windowUUID else { return NativeErrorPageState(
windowUUID: state.windowUUID,
title: state.title,
description: state.description
)}
switch action.actionType {
case NativeErrorPageActionType.reload:
case NativeErrorPageMiddlewareActionType.initialize:
guard let action = action as? NativeErrorPageAction, let model = action.nativePageErrorModel else {
return NativeErrorPageState(
windowUUID: state.windowUUID,
title: state.title,
description: state.description
)
}
return NativeErrorPageState(
windowUUID: state.windowUUID,
shouldReload: true,
// showProceedToURL: false,
// showLearnMore: false,
// showCertificate: false,
// shouldGoBack: false
model: state.model

title: model.errorTitle,
description: model.errorDescription
)
// case NativeErrorPageActionType.goBack:
// return NativeErrorPageState(
// windowUUID: state.windowUUID,
// shouldReload: false,
// showProceedToURL: false,
// showLearnMore: false,
// showCertificate: false,
// shouldGoBack: true
// )
// case NativeErrorPageActionType.tapAdvanced:
// return NativeErrorPageState(
// windowUUID: state.windowUUID,
// shouldReload: false,
// showProceedToURL: true,
// showLearnMore: false,
// showCertificate: false,
// shouldGoBack: false
// )
// case NativeErrorPageActionType.learMore:
// return NativeErrorPageState(
// windowUUID: state.windowUUID,
// shouldReload: false,
// showProceedToURL: false,
// showLearnMore: true,
// showCertificate: false,
// shouldGoBack: false
// )
// case NativeErrorPageActionType.viewCertificate:
// return NativeErrorPageState(
// windowUUID: state.windowUUID,
// shouldReload: false,
// showProceedToURL: false,
// showLearnMore: false,
// showCertificate: true,
// shouldGoBack: false
// )
default:
return NativeErrorPageState(
windowUUID: state.windowUUID,
shouldReload: false,
// showProceedToURL: false,
// showLearnMore: false,
// showCertificate: false,
// shouldGoBack: false
model: state.model

title: state.title,
description: state.description
)
}
}
Expand Down

0 comments on commit 2cacdf5

Please sign in to comment.