wip: complete new onboarding
This commit is contained in:
@@ -24,6 +24,7 @@ export class LumeStorage {
|
||||
|
||||
public async secureLoad(key?: string) {
|
||||
const value: string = await invoke('secure_load', { key });
|
||||
if (!value) return null;
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -45,8 +46,8 @@ export class LumeStorage {
|
||||
if (typeof account.follows === 'string')
|
||||
account.follows = JSON.parse(account.follows);
|
||||
|
||||
if (typeof account.network === 'string')
|
||||
account.network = JSON.parse(account.network);
|
||||
if (typeof account.circles === 'string')
|
||||
account.circles = JSON.parse(account.circles);
|
||||
|
||||
if (typeof account.last_login_at === 'string')
|
||||
account.last_login_at = parseInt(account.last_login_at);
|
||||
@@ -71,8 +72,8 @@ export class LumeStorage {
|
||||
]);
|
||||
} else {
|
||||
await this.db.execute(
|
||||
'INSERT OR IGNORE INTO accounts (npub, pubkey, privkey, is_active) VALUES ($1, $2, $3, $4);',
|
||||
[npub, pubkey, 'privkey is stored in secure storage', 1]
|
||||
'INSERT OR IGNORE INTO accounts (id, pubkey, is_active) VALUES ($1, $2, $3);',
|
||||
[npub, pubkey, 1]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -80,7 +81,7 @@ export class LumeStorage {
|
||||
return account;
|
||||
}
|
||||
|
||||
public async updateAccount(column: string, value: string | string[]) {
|
||||
public async updateAccount(column: string, value: string) {
|
||||
const insert = await this.db.execute(
|
||||
`UPDATE accounts SET ${column} = $1 WHERE id = $2;`,
|
||||
[value, this.account.id]
|
||||
@@ -298,12 +299,22 @@ export class LumeStorage {
|
||||
return await this.db.execute(`DELETE FROM relays WHERE relay = "${relay}";`);
|
||||
}
|
||||
|
||||
public async removePrivkey() {
|
||||
public async createSetting(key: string, value: string) {
|
||||
return await this.db.execute(
|
||||
`UPDATE accounts SET privkey = "privkey is stored in secure storage" WHERE id = "${this.account.id}";`
|
||||
'INSERT OR IGNORE INTO settings (key, value) VALUES ($1, $2);',
|
||||
[key, value]
|
||||
);
|
||||
}
|
||||
|
||||
public async getSettingValue(key: string) {
|
||||
const results: { key: string; value: string }[] = await this.db.select(
|
||||
'SELECT * FROM settings WHERE key = $1 ORDER BY id DESC LIMIT 1;',
|
||||
[key]
|
||||
);
|
||||
if (results.length < 1) return null;
|
||||
return results[0].value;
|
||||
}
|
||||
|
||||
public async accountLogout() {
|
||||
// update current account status
|
||||
await this.db.execute("UPDATE accounts SET is_active = '0' WHERE id = $1;", [
|
||||
|
||||
Reference in New Issue
Block a user