From de5b479c4707cd5070c9390c68f999f22f87f500 Mon Sep 17 00:00:00 2001 From: austinried <4966622+austinried@users.noreply.github.com> Date: Thu, 17 Jun 2021 13:01:47 +0900 Subject: [PATCH] building out settings db finally got transactions working too --- App.tsx | 4 +- src/clients.ts | 6 ++ src/components/Settings.tsx | 37 +++++++++++ src/db/client.ts | 67 ------------------- src/state/artists.ts | 4 +- src/storage/db.ts | 71 ++++++++++++++++++++ src/storage/music.ts | 19 ++++++ src/storage/settings.ts | 103 +++++++++++++++++++++++++++++ src/subsonic/{client.ts => api.ts} | 0 9 files changed, 240 insertions(+), 71 deletions(-) create mode 100644 src/clients.ts create mode 100644 src/components/Settings.tsx delete mode 100644 src/db/client.ts create mode 100644 src/storage/db.ts create mode 100644 src/storage/music.ts create mode 100644 src/storage/settings.ts rename src/subsonic/{client.ts => api.ts} (100%) diff --git a/App.tsx b/App.tsx index e5b8d85..5b7a91a 100644 --- a/App.tsx +++ b/App.tsx @@ -1,10 +1,10 @@ import React from 'react'; import { RecoilRoot } from 'recoil'; -import ArtistsList from './src/components/ArtistsList'; +import SettingsView from './src/components/Settings'; const App = () => ( - + ); diff --git a/src/clients.ts b/src/clients.ts new file mode 100644 index 0000000..c4a579d --- /dev/null +++ b/src/clients.ts @@ -0,0 +1,6 @@ +import { MusicDb } from "./storage/music"; +import { SettingsDb } from "./storage/settings"; +import { SubsonicApiClient } from "./subsonic/api"; + +export const musicDb = new MusicDb(); +export const settingsDb = new SettingsDb(); diff --git a/src/components/Settings.tsx b/src/components/Settings.tsx new file mode 100644 index 0000000..72cbfb8 --- /dev/null +++ b/src/components/Settings.tsx @@ -0,0 +1,37 @@ +import React from 'react'; +import { Button, View } from 'react-native'; +import { musicDb, settingsDb } from '../clients'; + +const DbControls = () => { + + const recreateMusicDb = async () => { + try { await musicDb.deleteDb(); } catch {} + await musicDb.createDb(); + } + + const recreateSettingsDb = async () => { + try { await settingsDb.deleteDb(); } catch {} + await settingsDb.createDb(); + } + + return ( + +