bitwarden-android/src/App/Services/SettingsService.cs

37 lines
1.1 KiB
C#
Raw Normal View History

2017-02-09 04:44:35 +03:00
using Bit.App.Abstractions;
using Plugin.Settings.Abstractions;
using System.Collections.Generic;
using System.Threading.Tasks;
using Newtonsoft.Json;
2017-02-09 04:44:35 +03:00
namespace Bit.App.Services
{
public class SettingsService : ISettingsService
{
private readonly ISettingsRepository _settingsRepository;
private readonly ISettings _settings;
private readonly IAuthService _authService;
2017-02-09 04:44:35 +03:00
public SettingsService(
ISettingsRepository settingsRepository,
ISettings settings,
IAuthService authService)
2017-02-09 04:44:35 +03:00
{
_settingsRepository = settingsRepository;
_settings = settings;
_authService = authService;
}
public async Task<IEnumerable<IEnumerable<string>>> GetEquivalentDomainsAsync()
{
var settings = await _settingsRepository.GetByIdAsync(_authService.UserId);
if(string.IsNullOrWhiteSpace(settings?.EquivalentDomains))
{
2017-02-10 06:06:39 +03:00
return new List<string[]>();
}
return JsonConvert.DeserializeObject<IEnumerable<IEnumerable<string>>>(settings.EquivalentDomains);
2017-02-09 04:44:35 +03:00
}
}
}