Fix for short profile Name value crashing app (#1833)

This commit is contained in:
Matt Portune 2022-03-09 09:00:04 -05:00 committed by GitHub
parent c043528a16
commit bf33f23c12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 2 deletions

View file

@ -62,6 +62,10 @@ namespace Bit.App.Controls
upperData = _data.ToUpper();
chars = GetFirstLetters(upperData, 2);
}
else
{
chars = upperData = _data.ToUpper();
}
var bgColor = StringToColor(upperData);
var textColor = Color.White;
@ -122,7 +126,7 @@ namespace Bit.App.Controls
{
return data.Substring(0, 2);
}
return null;
return data;
}
private Color StringToColor(string str)

View file

@ -55,6 +55,7 @@ namespace Bit.Core.Abstractions
Task SetAutofillTileAddedAsync(bool? value);
Task<string> GetEmailAsync(string userId = null);
Task<string> GetNameAsync(string userId = null);
Task SetNameAsync(string value, string userId = null);
Task<string> GetOrgIdentifierAsync(string userId = null);
Task<long?> GetLastActiveTimeAsync(string userId = null);
Task SetLastActiveTimeAsync(long? value, string userId = null);

View file

@ -470,6 +470,15 @@ namespace Bit.Core.Services
))?.Profile?.Name;
}
public async Task SetNameAsync(string value, string userId = null)
{
var reconciledOptions = ReconcileOptions(new StorageOptions { UserId = userId },
await GetDefaultStorageOptionsAsync());
var account = await GetAccountAsync(reconciledOptions);
account.Profile.Name = value;
await SaveAccountAsync(account, reconciledOptions);
}
public async Task<string> GetOrgIdentifierAsync(string userId = null)
{
return (await GetAccountAsync(

View file

@ -327,6 +327,7 @@ namespace Bit.Core.Services
var organizations = response.Organizations.ToDictionary(o => o.Id, o => new OrganizationData(o));
await _organizationService.ReplaceAsync(organizations);
await _stateService.SetEmailVerifiedAsync(response.EmailVerified);
await _stateService.SetNameAsync(response.Name);
await _keyConnectorService.SetUsesKeyConnector(response.UsesKeyConnector);
}

View file

@ -71,7 +71,7 @@ namespace Bit.iOS.Core.Renderers
{
try
{
uiBarButtonItem.Image = uiBarButtonItem.Image.ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal);
uiBarButtonItem.Image = uiBarButtonItem.Image?.ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal);
}
catch (ObjectDisposedException)
{