From d17789d5eecc521fea83019f5eeee88585ff161b Mon Sep 17 00:00:00 2001 From: Federico Maccaroni Date: Fri, 29 Sep 2023 12:27:12 -0300 Subject: [PATCH] PM-3349 PM-3350 MAUI Migration fix nullable bindings and fallbacks --- src/Core/Pages/Vault/BaseCipherViewModel.cs | 2 +- src/Core/Pages/Vault/CipherAddEditPage.xaml | 4 ++-- src/Core/Pages/Vault/CipherAddEditPageViewModel.cs | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Core/Pages/Vault/BaseCipherViewModel.cs b/src/Core/Pages/Vault/BaseCipherViewModel.cs index 7326872d8..671aca2a5 100644 --- a/src/Core/Pages/Vault/BaseCipherViewModel.cs +++ b/src/Core/Pages/Vault/BaseCipherViewModel.cs @@ -37,7 +37,7 @@ namespace Bit.App.Pages set => SetProperty(ref _cipher, value, additionalPropertyNames: AdditionalPropertiesToRaiseOnCipherChanged); } - public string CreationDate => string.Format(AppResources.CreatedXY, Cipher.CreationDate.ToShortDateString(), Cipher.CreationDate.ToShortTimeString()); + public string CreationDate => string.Format(AppResources.CreatedXY, Cipher?.CreationDate.ToShortDateString(), Cipher?.CreationDate.ToShortTimeString()); public AsyncCommand CheckPasswordCommand { get; } diff --git a/src/Core/Pages/Vault/CipherAddEditPage.xaml b/src/Core/Pages/Vault/CipherAddEditPage.xaml index 79b306e2a..1640f66d4 100644 --- a/src/Core/Pages/Vault/CipherAddEditPage.xaml +++ b/src/Core/Pages/Vault/CipherAddEditPage.xaml @@ -126,7 +126,7 @@ StyleClass="box-label" /> diff --git a/src/Core/Pages/Vault/CipherAddEditPageViewModel.cs b/src/Core/Pages/Vault/CipherAddEditPageViewModel.cs index bd34ca08f..ea68d137f 100644 --- a/src/Core/Pages/Vault/CipherAddEditPageViewModel.cs +++ b/src/Core/Pages/Vault/CipherAddEditPageViewModel.cs @@ -17,6 +17,8 @@ using Microsoft.Maui.Controls; using Microsoft.Maui; using Bit.App.Utilities; +#nullable enable + namespace Bit.App.Pages { public class CipherAddEditPageViewModel : BaseCipherViewModel @@ -883,7 +885,7 @@ namespace Bit.App.Pages Cipher.OrganizationId = OwnershipOptions[OwnershipSelectedIndex].Value; TriggerCipherChanged(); } - if (Cipher.OrganizationId != null) + if (Cipher?.OrganizationId != null) { var cols = _writeableCollections.Where(c => c.OrganizationId == Cipher.OrganizationId) .Select(c => new CollectionViewModel { Collection = c }).ToList();