1
0
mirror of https://github.com/bitwarden/mobile synced 2026-01-04 09:33:16 +00:00
This commit is contained in:
Kyle Spearrin
2016-05-03 19:49:49 -04:00
parent 92e74274e0
commit 24a5a16723
15 changed files with 250 additions and 77 deletions

View File

@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Bit.App.Abstractions;
using XLabs.Ioc;
@@ -10,6 +6,8 @@ namespace Bit.App.Models
{
public class CipherString
{
private string _decryptedValue;
public CipherString(string encryptedString)
{
if(string.IsNullOrWhiteSpace(encryptedString) || !encryptedString.Contains("|"))
@@ -43,8 +41,13 @@ namespace Bit.App.Models
public string Decrypt()
{
var cryptoService = Resolver.Resolve<ICryptoService>();
return cryptoService.Decrypt(this);
if(_decryptedValue == null)
{
var cryptoService = Resolver.Resolve<ICryptoService>();
_decryptedValue = cryptoService.Decrypt(this);
}
return _decryptedValue;
}
}
}

View File

@@ -27,6 +27,7 @@ namespace Bit.App.Models.Data
[PrimaryKey]
public string Id { get; set; }
[Indexed]
public string UserId { get; set; }
public string Name { get; set; }
public DateTime RevisionDateTime { get; set; } = DateTime.UtcNow;

View File

@@ -38,6 +38,7 @@ namespace Bit.App.Models.Data
[PrimaryKey]
public string Id { get; set; }
public string FolderId { get; set; }
[Indexed]
public string UserId { get; set; }
public string Name { get; set; }
public string Uri { get; set; }

View File

@@ -8,40 +8,39 @@ namespace Bit.App.Models.View
{
public class Site
{
public Site(Models.Site site)
public Site(Models.Site site, string folderId)
{
Id = site.Id;
FolderId = folderId;
Name = site.Name?.Decrypt();
Username = site.Username?.Decrypt();
}
public string Id { get; set; }
public string FolderId { get; set; }
public string Name { get; set; }
public string Username { get; set; }
}
public class Folder : ObservableCollection<Site>
{
public Folder(string name) { Name = name; }
public Folder(IEnumerable<Models.Site> sites)
public Folder(IEnumerable<Models.Site> sites, string folderId = null)
{
Name = "(none)";
foreach(var site in sites)
{
Items.Add(new Site(site));
Items.Add(new Site(site, folderId));
}
}
public Folder(Models.Folder folder, IEnumerable<Models.Site> sites)
: this(sites)
: this(sites, folder.Id)
{
Id = folder.Id;
Name = folder.Name?.Decrypt();
}
public string Id { get; set; }
public string Name { get; set; }
public string Name { get; set; } = "(none)";
public string FirstLetter { get { return Name.Substring(0, 1); } }
}
}