1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-11-21 11:25:56 +01:00

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)
{