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

null checks

This commit is contained in:
Kyle Spearrin 2018-10-06 17:28:40 -04:00
parent b7c6b65a3d
commit 525b5fa19a
4 changed files with 16 additions and 16 deletions

View File

@ -141,13 +141,13 @@ namespace Bit.iOS.Autofill
public void CompleteRequest(string username = null, string password = null, string totp = null)
{
if(_context.Configuring)
if((_context?.Configuring ?? true) && string.IsNullOrWhiteSpace(password))
{
ExtensionContext.CompleteExtensionConfigurationRequest();
ExtensionContext?.CompleteExtensionConfigurationRequest();
return;
}
if(string.IsNullOrWhiteSpace(username) && string.IsNullOrWhiteSpace(password))
if(_context == null || string.IsNullOrWhiteSpace(password))
{
_googleAnalyticsService.TrackAutofillExtensionEvent("Canceled");
var err = new NSError(new NSString("ASExtensionErrorDomain"),
@ -156,7 +156,7 @@ namespace Bit.iOS.Autofill
{
NSRunLoop.Main.BeginInvokeOnMainThread(() =>
{
ExtensionContext.CancelRequest(err);
ExtensionContext?.CancelRequest(err);
});
});
return;
@ -173,7 +173,7 @@ namespace Bit.iOS.Autofill
{
NSRunLoop.Main.BeginInvokeOnMainThread(() =>
{
ExtensionContext.CompleteRequest(cred, null);
ExtensionContext?.CompleteRequest(cred, null);
});
});
}
@ -233,7 +233,7 @@ namespace Bit.iOS.Autofill
PerformSegue("setupSegue", this);
return;
}
if (_context.ServiceIdentifiers == null || _context.ServiceIdentifiers.Length == 0)
if(_context.ServiceIdentifiers == null || _context.ServiceIdentifiers.Length == 0)
{
PerformSegue("loginSearchSegue", this);
}

View File

@ -26,21 +26,21 @@ namespace Bit.iOS.Core.Utilities
}
if (identities.Any())
{
await ASCredentialIdentityStore.SharedStore.ReplaceCredentialIdentitiesAsync(identities.ToArray());
await ASCredentialIdentityStore.SharedStore?.ReplaceCredentialIdentitiesAsync(identities.ToArray());
}
}
}
public static async Task<bool> IdentitiesCanIncremental()
{
var state = await ASCredentialIdentityStore.SharedStore.GetCredentialIdentityStoreStateAsync();
return state.Enabled && state.SupportsIncrementalUpdates;
var state = await ASCredentialIdentityStore.SharedStore?.GetCredentialIdentityStoreStateAsync();
return state != null && state.Enabled && state.SupportsIncrementalUpdates;
}
public static async Task<bool> AutofillEnabled()
{
var state = await ASCredentialIdentityStore.SharedStore.GetCredentialIdentityStoreStateAsync();
return state.Enabled;
var state = await ASCredentialIdentityStore.SharedStore?.GetCredentialIdentityStoreStateAsync();
return state != null && state.Enabled;
}
public static async Task<ASPasswordCredentialIdentity> GetCipherIdentityAsync(string cipherId, ICipherService cipherService)

View File

@ -81,9 +81,9 @@ namespace Bit.iOS.Core.Views
{
searchFilter = searchFilter.ToLower();
Items = _allItems
.Where(s => s.Name.ToLower().Contains(searchFilter) ||
.Where(s => s.Name?.ToLower().Contains(searchFilter) ?? false ||
(s.Username?.ToLower().Contains(searchFilter) ?? false) ||
(s.Uris?.FirstOrDefault()?.Uri.ToLower().Contains(searchFilter) ?? false))
(s.Uris?.FirstOrDefault()?.Uri?.ToLower().Contains(searchFilter) ?? false))
.TakeWhile(s => !ct.IsCancellationRequested)
.ToArray();
}

View File

@ -169,7 +169,7 @@ namespace Bit.iOS
{
return;
}
await ASCredentialIdentityStore.SharedStore.SaveCredentialIdentitiesAsync(
await ASCredentialIdentityStore.SharedStore?.SaveCredentialIdentitiesAsync(
new ASPasswordCredentialIdentity[] { identity });
return;
}
@ -190,7 +190,7 @@ namespace Bit.iOS
{
return;
}
await ASCredentialIdentityStore.SharedStore.RemoveCredentialIdentitiesAsync(
await ASCredentialIdentityStore.SharedStore?.RemoveCredentialIdentitiesAsync(
new ASPasswordCredentialIdentity[] { identity });
return;
}
@ -203,7 +203,7 @@ namespace Bit.iOS
{
if(_deviceInfoService.Version >= 12)
{
await ASCredentialIdentityStore.SharedStore.RemoveAllCredentialIdentitiesAsync();
await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync();
}
});