update onboarding pages

This commit is contained in:
Ren Amamiya
2023-04-27 18:04:21 +07:00
parent 98a37d4618
commit b2b5cb50f0
9 changed files with 447 additions and 315 deletions

View File

@@ -16,7 +16,7 @@ export async function connect(): Promise<Database> {
export async function getActiveAccount() {
const db = await connect();
// #TODO: check is_active == true
const result = await db.select(`SELECT * FROM accounts LIMIT 1;`);
const result = await db.select(`SELECT * FROM accounts WHERE is_active = 1 LIMIT 1;`);
return result[0];
}
@@ -27,13 +27,18 @@ export async function getAccounts() {
}
// create account
export async function createAccount(pubkey: string, privkey: string, metadata: string) {
export async function createAccount(
pubkey: string,
privkey: string,
metadata: string,
follows?: string[][],
is_active?: number
) {
const db = await connect();
return await db.execute('INSERT OR IGNORE INTO accounts (pubkey, privkey, metadata) VALUES (?, ?, ?);', [
pubkey,
privkey,
metadata,
]);
return await db.execute(
'INSERT OR IGNORE INTO accounts (pubkey, privkey, metadata, follows, is_active) VALUES (?, ?, ?, ?, ?);',
[pubkey, privkey, metadata, follows || '', is_active || 0]
);
}
// update account