mirror of
https://github.com/austinried/subtracks.git
synced 2026-02-11 15:22:43 +01:00
basic tab navigation
other things
This commit is contained in:
@@ -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 (
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user