1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-11-23 11:45:38 +01:00

null checks on _tableItems

This commit is contained in:
Kyle Spearrin 2017-05-19 11:20:47 -04:00
parent 825b76e28e
commit 0abf054825

View File

@ -115,7 +115,7 @@ namespace Bit.iOS.Extension
{ {
var loginService = Resolver.Resolve<ILoginService>(); var loginService = Resolver.Resolve<ILoginService>();
var logins = await loginService.GetAllAsync(_context.UrlString); var logins = await loginService.GetAllAsync(_context.UrlString);
_tableItems = logins?.Item1.Select(s => new LoginViewModel(s)) _tableItems = logins?.Item1?.Select(s => new LoginViewModel(s))
.OrderBy(s => s.Name) .OrderBy(s => s.Name)
.ThenBy(s => s.Username) .ThenBy(s => s.Username)
.ToList() ?? new List<LoginViewModel>(); .ToList() ?? new List<LoginViewModel>();
@ -125,12 +125,12 @@ namespace Bit.iOS.Extension
public override nint RowsInSection(UITableView tableview, nint section) public override nint RowsInSection(UITableView tableview, nint section)
{ {
return _tableItems.Count() == 0 ? 1 : _tableItems.Count(); return _tableItems == null || _tableItems.Count() == 0 ? 1 : _tableItems.Count();
} }
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
{ {
if(_tableItems.Count() == 0) if(_tableItems == null || _tableItems.Count() == 0)
{ {
var noDataCell = new UITableViewCell(UITableViewCellStyle.Default, "NoDataCell"); var noDataCell = new UITableViewCell(UITableViewCellStyle.Default, "NoDataCell");
noDataCell.TextLabel.Text = AppResources.NoLoginsTap; noDataCell.TextLabel.Text = AppResources.NoLoginsTap;
@ -154,7 +154,7 @@ namespace Bit.iOS.Extension
public override void WillDisplay(UITableView tableView, UITableViewCell cell, NSIndexPath indexPath) public override void WillDisplay(UITableView tableView, UITableViewCell cell, NSIndexPath indexPath)
{ {
if(_tableItems.Count() == 0 || cell == null) if(_tableItems == null || _tableItems.Count() == 0 || cell == null)
{ {
return; return;
} }
@ -169,7 +169,7 @@ namespace Bit.iOS.Extension
tableView.DeselectRow(indexPath, true); tableView.DeselectRow(indexPath, true);
tableView.EndEditing(true); tableView.EndEditing(true);
if(_tableItems.Count() == 0) if(_tableItems == null || _tableItems.Count() == 0)
{ {
_controller.PerformSegue("loginAddSegue", this); _controller.PerformSegue("loginAddSegue", this);
return; return;