Prevent double initializing typeorm

App is re-mounted when the system theme is changed,
but the connection to the sqlite database stays active.
This means the previous code would fail to initialize
and then be a blank screen.
Closes #107
This commit is contained in:
Brandon Presley 2022-11-02 15:37:32 +13:00
parent 187a0fbc68
commit 8835a3efd3
1 changed files with 1 additions and 1 deletions

View File

@ -54,7 +54,7 @@ const App = () => {
console.log(`${Routes.name}.toast:`, {value})
setSnackbar(value)
})
if (AppDataSource.isInitialized) return
if (AppDataSource.isInitialized) return setInitialized(true)
AppDataSource.initialize().then(async () => {
const settings = await settingsRepo.findOne({where: {}})
console.log(`${App.name}.useEffect:`, {gotSettings: settings})