Minor improvements on save/getDevice
This commit is contained in:
parent
5b153edab8
commit
3cb52b6ebb
@ -425,9 +425,14 @@ export default class Services {
|
||||
|
||||
async saveDeviceInDatabase(device: any): Promise<void> {
|
||||
const db = await Database.getInstance();
|
||||
const walletStore = 'wallet';
|
||||
try {
|
||||
const prevDevice = await this.getDeviceFromDatabase();
|
||||
if (prevDevice) {
|
||||
await db.deleteObject(walletStore, "1");
|
||||
}
|
||||
await db.addObject({
|
||||
storeName: 'wallet',
|
||||
storeName: walletStore,
|
||||
object: { pre_id: '1', device },
|
||||
key: null,
|
||||
});
|
||||
@ -438,8 +443,9 @@ export default class Services {
|
||||
|
||||
async getDeviceFromDatabase(): Promise<string | null> {
|
||||
const db = await Database.getInstance();
|
||||
const walletStore = 'wallet';
|
||||
try {
|
||||
const dbRes = await db.getObject('wallet', '1');
|
||||
const dbRes = await db.getObject(walletStore, '1');
|
||||
if (dbRes) {
|
||||
const wallet = dbRes['device'];
|
||||
return wallet;
|
||||
|
Loading…
x
Reference in New Issue
Block a user