Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
ensure dialog waits for all results
Browse files Browse the repository at this point in the history
  • Loading branch information
rebeccamadsen committed Jan 28, 2022
1 parent a8eb32a commit 7bdd0a3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
5 changes: 4 additions & 1 deletion src/main/MainApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ const createApp = () => {
defaultId: 0,
}).then(({ response }) => {
if (response === 1) {
protocolManager.correctSessionVariableTypes();
protocolManager.correctSessionVariableTypes()
.catch((err) => {
dialog.showErrorBox('Correct Variable Types Error', err && err.message);
});
}
});

Expand Down
23 changes: 11 additions & 12 deletions src/main/data-managers/ProtocolManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -682,14 +682,14 @@ class ProtocolManager {
async correctSessionVariableTypes() {
let changesMade = false;

await this.allProtocols().then((allProtocols) => {
allProtocols.forEach((protocol) => {
await this.allProtocols().then((allProtocols) => (
promiseWithStaleEmitter(Promise.allSettled(allProtocols.map((protocol) => {
const protocolId = get(protocol, '_id');
this.getProtocolSessions(protocolId)
.then((sessions) => {
sessions.forEach((session) => {
return this.getProtocolSessions(protocolId)
.then((sessions) => (
Promise.allSettled(sessions.map((session) => {
const sessionId = get(session, '_id');
this.getProtocolSession(protocolId, sessionId)
return this.getProtocolSession(protocolId, sessionId)
.then((sessionData) => {
const nodes = getCorrectEntityVariableTypes(sessionData.data.nodes,
protocol.codebook.node);
Expand All @@ -709,15 +709,14 @@ class ProtocolManager {
ego: ego.correctedEntity,
},
};
return promiseWithStaleEmitter(this.sessionDb.update(protocolId,
updatedSession));
return this.sessionDb.update(protocolId, updatedSession);
}
return Promise.resolve;
});
});
});
});
});
}))
));
})))
));

if (changesMade) {
dialog.showMessageBox(null, {
Expand Down

0 comments on commit 7bdd0a3

Please sign in to comment.