mirror of
https://github.com/bitwarden/mobile
synced 2025-12-18 09:13:15 +00:00
Set push token state values to be user-specific (#2200)
* Changed the current push token and last registration time to be user-based * Fixed compile error. * Fixed interface implementation. * Fixed compile error for Android. * Refactored to handle getting active user ID within state service * Refactored methods allow existing logic to handle getting the active user. * Updated to reconcile options. * Updated naming and fixed issue with UserId. * Removed space between constants.
This commit is contained in:
@@ -1009,18 +1009,18 @@ namespace Bit.Core.Services
|
||||
await SetValueAsync(key, value, options);
|
||||
}
|
||||
|
||||
public async Task<DateTime?> GetPushLastRegistrationDateAsync()
|
||||
public async Task<DateTime?> GetPushLastRegistrationDateAsync(string userId = null)
|
||||
{
|
||||
var options = await GetDefaultStorageOptionsAsync();
|
||||
var key = Constants.PushLastRegistrationDateKey;
|
||||
return await GetValueAsync<DateTime?>(key, options);
|
||||
var reconciledOptions = ReconcileOptions(new StorageOptions { UserId = userId }, await GetDefaultStorageOptionsAsync());
|
||||
var key = Constants.PushLastRegistrationDateKey(reconciledOptions.UserId);
|
||||
return await GetValueAsync<DateTime?>(key, reconciledOptions);
|
||||
}
|
||||
|
||||
public async Task SetPushLastRegistrationDateAsync(DateTime? value)
|
||||
public async Task SetPushLastRegistrationDateAsync(DateTime? value, string userId = null)
|
||||
{
|
||||
var options = await GetDefaultStorageOptionsAsync();
|
||||
var key = Constants.PushLastRegistrationDateKey;
|
||||
await SetValueAsync(key, value, options);
|
||||
var reconciledOptions = ReconcileOptions(new StorageOptions { UserId = userId }, await GetDefaultStorageOptionsAsync());
|
||||
var key = Constants.PushLastRegistrationDateKey(reconciledOptions.UserId);
|
||||
await SetValueAsync(key, value, reconciledOptions);
|
||||
}
|
||||
|
||||
public async Task<string> GetPushInstallationRegistrationErrorAsync()
|
||||
@@ -1037,18 +1037,18 @@ namespace Bit.Core.Services
|
||||
await SetValueAsync(key, value, options);
|
||||
}
|
||||
|
||||
public async Task<string> GetPushCurrentTokenAsync()
|
||||
public async Task<string> GetPushCurrentTokenAsync(string userId = null)
|
||||
{
|
||||
var options = await GetDefaultStorageOptionsAsync();
|
||||
var key = Constants.PushCurrentTokenKey;
|
||||
return await GetValueAsync<string>(key, options);
|
||||
var reconciledOptions = ReconcileOptions(new StorageOptions { UserId = userId }, await GetDefaultStorageOptionsAsync());
|
||||
var key = Constants.PushCurrentTokenKey(reconciledOptions.UserId);
|
||||
return await GetValueAsync<string>(key, reconciledOptions);
|
||||
}
|
||||
|
||||
public async Task SetPushCurrentTokenAsync(string value)
|
||||
public async Task SetPushCurrentTokenAsync(string value, string userId = null)
|
||||
{
|
||||
var options = await GetDefaultStorageOptionsAsync();
|
||||
var key = Constants.PushCurrentTokenKey;
|
||||
await SetValueAsync(key, value, options);
|
||||
var reconciledOptions = ReconcileOptions(new StorageOptions { UserId = userId }, await GetDefaultStorageOptionsAsync());
|
||||
var key = Constants.PushCurrentTokenKey(reconciledOptions.UserId);
|
||||
await SetValueAsync(key, value, reconciledOptions);
|
||||
}
|
||||
|
||||
public async Task<List<EventData>> GetEventCollectionAsync()
|
||||
|
||||
Reference in New Issue
Block a user