diff --git a/src/Android/MainApplication.cs b/src/Android/MainApplication.cs index f591539fd..1716e0f75 100644 --- a/src/Android/MainApplication.cs +++ b/src/Android/MainApplication.cs @@ -220,6 +220,7 @@ namespace Bit.Android .RegisterType(new ContainerControlledLifetimeManager()) .RegisterType(new ContainerControlledLifetimeManager()) .RegisterType(new ContainerControlledLifetimeManager()) + .RegisterType(new ContainerControlledLifetimeManager()) // Other .RegisterInstance(CrossSettings.Current, new ContainerControlledLifetimeManager()) .RegisterInstance(CrossConnectivity.Current, new ContainerControlledLifetimeManager()) diff --git a/src/App/Abstractions/Repositories/IRepository.cs b/src/App/Abstractions/Repositories/IRepository.cs index 4bf4e762d..2ad5d8246 100644 --- a/src/App/Abstractions/Repositories/IRepository.cs +++ b/src/App/Abstractions/Repositories/IRepository.cs @@ -12,6 +12,7 @@ namespace Bit.App.Abstractions Task> GetAllAsync(); Task UpdateAsync(T obj); Task InsertAsync(T obj); + Task UpsertAsync(T obj); Task DeleteAsync(TId id); Task DeleteAsync(T obj); } diff --git a/src/App/Abstractions/Repositories/ISettingsRepository.cs b/src/App/Abstractions/Repositories/ISettingsRepository.cs new file mode 100644 index 000000000..e3f9b8c18 --- /dev/null +++ b/src/App/Abstractions/Repositories/ISettingsRepository.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Bit.App.Abstractions +{ + public interface ISettingsRepository + { + Task>> GetEquivablentDomains(string userId); + } +} diff --git a/src/App/App.csproj b/src/App/App.csproj index 3d9bf5330..8a4d15fcd 100644 --- a/src/App/App.csproj +++ b/src/App/App.csproj @@ -37,6 +37,7 @@ + @@ -101,6 +102,7 @@ + @@ -149,6 +151,7 @@ + diff --git a/src/App/Models/Data/SettingsData.cs b/src/App/Models/Data/SettingsData.cs new file mode 100644 index 000000000..12d08a09a --- /dev/null +++ b/src/App/Models/Data/SettingsData.cs @@ -0,0 +1,16 @@ +using SQLite; +using Bit.App.Abstractions; + +namespace Bit.App.Models.Data +{ + [Table("Settings")] + public class SettingsData : IDataObject + { + public SettingsData() + { } + + [PrimaryKey] + public string Id { get; set; } + public string EquivalentDomains { get; set; } + } +} diff --git a/src/App/Repositories/Repository.cs b/src/App/Repositories/Repository.cs index 54b4af6b2..8be6118c8 100644 --- a/src/App/Repositories/Repository.cs +++ b/src/App/Repositories/Repository.cs @@ -39,6 +39,11 @@ namespace Bit.App.Repositories Connection.Update(obj); return Task.FromResult(0); } + public virtual Task UpsertAsync(T obj) + { + Connection.InsertOrReplace(obj); + return Task.FromResult(0); + } public virtual async Task DeleteAsync(T obj) { diff --git a/src/App/Repositories/SettingsRepository.cs b/src/App/Repositories/SettingsRepository.cs new file mode 100644 index 000000000..9d55c13d3 --- /dev/null +++ b/src/App/Repositories/SettingsRepository.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Bit.App.Abstractions; +using Bit.App.Models.Data; +using Newtonsoft.Json; + +namespace Bit.App.Repositories +{ + public class SettingsRepository : Repository, ISettingsRepository + { + public SettingsRepository(ISqlService sqlService) + : base(sqlService) + { } + + public Task>> GetEquivablentDomains(string userId) + { + var equivalentDomainsJson = Connection.Table().Where(f => f.Id == userId) + .Select(f => f.EquivalentDomains).FirstOrDefault(); + + if(string.IsNullOrWhiteSpace(equivalentDomainsJson)) + { + return Task.FromResult>>(null); + } + + var equivalentDomains = JsonConvert.DeserializeObject>>(equivalentDomainsJson); + return Task.FromResult(equivalentDomains); + } + } +} diff --git a/src/App/Services/DatabaseService.cs b/src/App/Services/DatabaseService.cs index 66ffe13f7..9c68a985d 100644 --- a/src/App/Services/DatabaseService.cs +++ b/src/App/Services/DatabaseService.cs @@ -18,6 +18,7 @@ namespace Bit.App.Services { _connection.CreateTable(); _connection.CreateTable(); + _connection.CreateTable(); } } } diff --git a/src/iOS.Extension/LoadingViewController.cs b/src/iOS.Extension/LoadingViewController.cs index 46c273af9..42ca3da49 100644 --- a/src/iOS.Extension/LoadingViewController.cs +++ b/src/iOS.Extension/LoadingViewController.cs @@ -287,6 +287,7 @@ namespace Bit.iOS.Extension .RegisterType(new ContainerControlledLifetimeManager()) .RegisterType(new ContainerControlledLifetimeManager()) .RegisterType(new ContainerControlledLifetimeManager()) + .RegisterType(new ContainerControlledLifetimeManager()) // Other .RegisterInstance(CrossConnectivity.Current, new ContainerControlledLifetimeManager()) .RegisterInstance(CrossFingerprint.Current, new ContainerControlledLifetimeManager()); diff --git a/src/iOS/AppDelegate.cs b/src/iOS/AppDelegate.cs index d30038ced..9c339f0da 100644 --- a/src/iOS/AppDelegate.cs +++ b/src/iOS/AppDelegate.cs @@ -276,6 +276,7 @@ namespace Bit.iOS .RegisterType(new ContainerControlledLifetimeManager()) .RegisterType(new ContainerControlledLifetimeManager()) .RegisterType(new ContainerControlledLifetimeManager()) + .RegisterType(new ContainerControlledLifetimeManager()) // Other .RegisterInstance(CrossConnectivity.Current, new ContainerControlledLifetimeManager()) .RegisterInstance(UserDialogs.Instance, new ContainerControlledLifetimeManager())