basic tab navigation

other things
This commit is contained in:
austinried
2021-06-18 13:00:12 +09:00
parent de5b479c47
commit 0f1e10d50f
16 changed files with 912 additions and 59 deletions

View File

@@ -9,9 +9,9 @@ export abstract class DbStorage {
this.dbParams = dbParams;
}
// abstract createDb(): Promise<void>
abstract createDb(): Promise<void>
protected async createDb(scope: (tx: Transaction) => void): Promise<void> {
protected async initDb(scope: (tx: Transaction) => void): Promise<void> {
await this.transaction(tx => {
tx.executeSql(`
CREATE TABLE db_version (

View File

@@ -6,7 +6,7 @@ export class MusicDb extends DbStorage {
}
async createDb(): Promise<void> {
super.createDb(tx => {
await this.initDb(tx => {
tx.executeSql(`
CREATE TABLE artists (
id TEXT PRIMARY KEY NOT NULL,

View File

@@ -18,7 +18,7 @@ export class SettingsDb extends DbStorage {
}
async createDb(): Promise<void> {
super.createDb(tx => {
await this.initDb(tx => {
tx.executeSql(`
CREATE TABLE servers (
id TEXT PRIMARY KEY NOT NULL,
@@ -56,32 +56,32 @@ export class SettingsDb extends DbStorage {
return (await this.getServers()).find(x => x.id === id);
}
async addServer(server: ServerSettings): Promise<void> {
await this.executeSql(`
INSERT INTO servers (id, address, username, token, salt)
VALUES (?, ?, ?, ?, ?);
`, [server.id, server.address, server.username, server.token, server.salt]);
}
// async addServer(server: ServerSettings): Promise<void> {
// await this.executeSql(`
// INSERT INTO servers (id, address, username, token, salt)
// VALUES (?, ?, ?, ?, ?);
// `, [server.id, server.address, server.username, server.token, server.salt]);
// }
async removeServer(id: string): Promise<void> {
await this.executeSql(`
DELETE FROM servers
WHERE id = ?;
`, [id]);
}
// async removeServer(id: string): Promise<void> {
// await this.executeSql(`
// DELETE FROM servers
// WHERE id = ?;
// `, [id]);
// }
async updateServer(server: ServerSettings): Promise<void> {
await this.executeSql(`
UPDATE servers SET
address = ?,
username = ?,
token = ?,
salt = ?
WHERE id = ?;
`, [
server.address, server.username, server.token, server.salt,
server.id,
]);
async updateServers(servers: ServerSettings[]): Promise<void> {
await this.transaction((tx) => {
tx.executeSql(`
DELETE FROM servers
`);
for (const s of servers) {
tx.executeSql(`
INSERT INTO servers (id, address, username, token, salt)
VALUES (?, ?, ?, ?, ?);
`, [s.id, s.address, s.username, s.token, s.salt]);
}
});
}
async getApp(): Promise<AppSettings> {