forked from mirrors/linphone-iphone
Add a check to avoid out-of-bounds index error in ContentView.swift
This commit is contained in:
parent
e74df76301
commit
7e1e3adf8d
1 changed files with 13 additions and 4 deletions
|
|
@ -340,13 +340,22 @@ struct ContentView: View {
|
|||
openMenu()
|
||||
}
|
||||
.onAppear {
|
||||
imagePath = CoreContext.shared.accounts[accountProfileViewModel.accountModelIndex!].getImagePath()
|
||||
if let accountModelIndex = accountProfileViewModel.accountModelIndex,
|
||||
accountModelIndex < CoreContext.shared.accounts.count {
|
||||
imagePath = CoreContext.shared.accounts[accountModelIndex].getImagePath()
|
||||
}
|
||||
}
|
||||
.onChange(of: CoreContext.shared.accounts[accountProfileViewModel.accountModelIndex!].usernaneAvatar) { _ in
|
||||
imagePath = CoreContext.shared.accounts[accountProfileViewModel.accountModelIndex!].getImagePath()
|
||||
.onChange(of: CoreContext.shared.accounts[accountProfileViewModel.accountModelIndex ?? 0].usernaneAvatar) { _ in
|
||||
if let accountModelIndex = accountProfileViewModel.accountModelIndex,
|
||||
accountModelIndex < CoreContext.shared.accounts.count {
|
||||
imagePath = CoreContext.shared.accounts[accountModelIndex].getImagePath()
|
||||
}
|
||||
}
|
||||
.onReceive(imageChanged) { _ in
|
||||
imagePath = CoreContext.shared.accounts[accountProfileViewModel.accountModelIndex!].getImagePath()
|
||||
if let accountModelIndex = accountProfileViewModel.accountModelIndex,
|
||||
accountModelIndex < CoreContext.shared.accounts.count {
|
||||
imagePath = CoreContext.shared.accounts[accountModelIndex].getImagePath()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue