Skip to content

Commit

Permalink
fix: glitch on logout and re-login db get cleaned and fail on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
geolffreym committed Apr 30, 2021
1 parent 121ad80 commit e51bdce
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/main/core/broker/broker.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,25 @@ module.exports = class Broker extends EventEmitter {
constructor(renderer) {
super()
this.renderer = renderer;
this.initStore();

}

initDB() {
initStore() {
/**
* Initialize db
* Singleton initialize db
* @type {function(*=): void}
*/
log.warn('Creating local db')
this.db = new LinvoDB(DB)//, MOVIES_SCHEMA, {})
if (this.db) return this.db;
this.db = new LinvoDB(DB)
}

flush() {
/**
* Kill all this shit XD
* */
log.warn('Flushing app')

this.db.remove({}, {multi: true},
(err, numRemoved) => {
if (err) log.error(err)
Expand Down Expand Up @@ -168,7 +170,6 @@ module.exports = class Broker extends EventEmitter {
log.info(collection[0]['_id']); // get id for ingested chunk
const total = this.db.getAllData().length;
const firstChunk = Object.is(total, 0);

this.db.insert(collection, (e, n) => {
if (e) return; // Avoid `n.length` undefined
if (firstChunk) {
Expand All @@ -191,7 +192,6 @@ module.exports = class Broker extends EventEmitter {
*/
// Clean old listeners first
log.info('Broker ready')
this.initDB();
this.stopIpcEvents();
this.emitStart();
this.listenForPartyRock();
Expand Down
3 changes: 1 addition & 2 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ app.on('ready', async () => {
})
}


})

// Disable cors errors
Expand Down Expand Up @@ -228,7 +227,7 @@ app.whenReady().then(() => {
ipcMain.on('party', async () => {
if (key.existKey) await removeFiles(key.keyFile)
ipcMain.emit('party-success') // Just after key being removed
removeCacheDirs(); // Clean old data dir
// removeCacheDirs(); // Clean old data dir
})

ipcMain.on('focus', () => win.focus())
Expand Down

0 comments on commit e51bdce

Please sign in to comment.