Merge branch 'bugfix/tabbar_index_crash_fix' into 'release/11_1_4'

Bugfix/tabbar index crash fix

### Summary
Top crash prevention when the web bridge gives an invalid tab index.

### Crash Signature
https://console.firebase.google.com/project/api-project-396418606732/crashlytics/app/ios:com.vzw.hss.myverizon/issues/d55575695f799d0b41da74b063331db6?time=last-seven-days&types=crash&sessionEventKey=85086f6b016242f0b3ef04b40d6e46a6_1886152816176443688

```
Crashed: com.apple.main-thread
0  MVMCoreUI                      0x38ed04 TabBar.highlightTab(at:) + 90 (TabBar.swift:90)
1  MVMCoreUI                      0x38ed34 @objc TabBar.highlightTab(at:) + 7800 (<compiler-generated>:7800)
2  MobileFirstFramework           0x48fb94 MVMCoreViewControllerProtocol<>.update(_:) + 57 (WebviewBridgeWebPageLoaded.swift:57)
3  MobileFirstFramework           0x954288 (1) suspend resume partial function for closure #1 in WebViewBridgeUpdateTabBar.performBridgeAction(with:viewController:completionHandler:) + 20 (WebViewBridgeUpdateTabBar.swift:20)
```

See merge request https://gitlab.verizon.com/BPHV_MIPS/mvm_core_ui/-/merge_requests/1033
This commit is contained in:
Hedden, Kyle Matthew 2023-12-01 19:35:36 +00:00
commit e48867446c

View File

@ -84,16 +84,22 @@ import VDSColorTokens
// MARK: - TabBarProtocol
@MainActor
public func highlightTab(at index: Int) {
guard let newSelectedItem = items?[index] else { return }
guard let items = items, index >= 0, index < items.count else {
MVMCoreLoggingHandler.shared()?.addError(toLog: MVMCoreErrorObject(title: nil, messageToLog: "Invalid tab index \(index). \(items?.count ?? 0) tabs available .", code: 0, domain: ErrorDomainSystem, location: #function)!)
return
}
tabModel.selectedTab = index
selectedItem = newSelectedItem
selectedItem = items[index]
}
@MainActor
public func selectTab(at index: Int) {
guard let newSelectedItem = items?[index] else { return }
selectedItem = newSelectedItem
tabBar(self, didSelect: newSelectedItem)
guard let items = items, index >= 0, index < items.count else {
MVMCoreLoggingHandler.shared()?.addError(toLog: MVMCoreErrorObject(title: nil, messageToLog: "Invalid tab index \(index). \(items?.count ?? 0) tabs available.", code: 0, domain: ErrorDomainSystem, location: #function)!)
return
}
selectedItem = items[index]
tabBar(self, didSelect: items[index])
}
public func currentTabIndex() -> Int { tabModel.selectedTab }