const promises = [];
const convos = chats.map(chat => {
const convo = new Conversation(chat,db);
promises.push(new Promise(resolve => {
convo.on("ready", resolve);
}));
return convo;
});
Promise.all(promises).then(_ => {
mainWindow.chats = convos;
mainWindow.loadFile(path.join(__dirname, 'src', 'render','index.html'));
});