Altered save_attempt to handle undefined and true cases for replace_on_complete
When fastItemAdd is not used, replace_on_complete is undefined
When it is used, and successful, replace_on_complete will be set to true
then we need it to execute result.on_complete()
Signed-off-by: Blake Henderson <blake@mobiusconsortium.org>
Signed-off-by: Remington Steed <rjs7@calvin.edu>
Signed-off-by: Ben Shum <bshum@biblio.org>
if (result.id) {
replace_on_complete = fastItemAdd_attempt(result.id);
}
- if (!replace_on_complete && typeof result.on_complete == 'function') {
+ // When fastItemAdd is not used, replace_on_complete is undefined
+ // When it is used, and successful, replace_on_complete will be set to true
+ // then we need it to execute on_complete()
+ if ((replace_on_complete==undefined || replace_on_complete ) && typeof result.on_complete == 'function') {
result.on_complete();
}
}