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> {
|
async saveDeviceInDatabase(device: any): Promise<void> {
|
||||||
const db = await Database.getInstance();
|
const db = await Database.getInstance();
|
||||||
|
const walletStore = 'wallet';
|
||||||
try {
|
try {
|
||||||
|
const prevDevice = await this.getDeviceFromDatabase();
|
||||||
|
if (prevDevice) {
|
||||||
|
await db.deleteObject(walletStore, "1");
|
||||||
|
}
|
||||||
await db.addObject({
|
await db.addObject({
|
||||||
storeName: 'wallet',
|
storeName: walletStore,
|
||||||
object: { pre_id: '1', device },
|
object: { pre_id: '1', device },
|
||||||
key: null,
|
key: null,
|
||||||
});
|
});
|
||||||
@ -438,8 +443,9 @@ export default class Services {
|
|||||||
|
|
||||||
async getDeviceFromDatabase(): Promise<string | null> {
|
async getDeviceFromDatabase(): Promise<string | null> {
|
||||||
const db = await Database.getInstance();
|
const db = await Database.getInstance();
|
||||||
|
const walletStore = 'wallet';
|
||||||
try {
|
try {
|
||||||
const dbRes = await db.getObject('wallet', '1');
|
const dbRes = await db.getObject(walletStore, '1');
|
||||||
if (dbRes) {
|
if (dbRes) {
|
||||||
const wallet = dbRes['device'];
|
const wallet = dbRes['device'];
|
||||||
return wallet;
|
return wallet;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user