mirror of
https://github.com/nasa/openmct.git
synced 2025-02-21 09:52:04 +00:00
[Persistence] Resolve correct promise from queue
Make sure that the correct promise is resolved when a persistence queue flush completes; some operations, like Save in Edit mode, wait on this promise, so it needs to resolve when persistence of that group is completed. WTD-1033.
This commit is contained in:
parent
821cc65d6f
commit
2709fde9a3
@ -34,15 +34,22 @@ define(
|
||||
return Object.keys(queue).length === lastObservedSize;
|
||||
}
|
||||
|
||||
// Clear the active promise for a queue flush
|
||||
function clearFlushPromise(value) {
|
||||
flushPromise = undefined;
|
||||
activeDefer.resolve(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
// Persist all queued objects
|
||||
function flush() {
|
||||
// Get a local reference to the active promise;
|
||||
// this will be replaced with a promise for the next round
|
||||
// of persistence calls, so we want to make sure we clear
|
||||
// the correct one when this flush completes.
|
||||
var flushingDefer = activeDefer;
|
||||
|
||||
// Clear the active promise for a queue flush
|
||||
function clearFlushPromise(value) {
|
||||
flushPromise = undefined;
|
||||
flushingDefer.resolve(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
// Persist all queued objects
|
||||
flushPromise = handler.persist(queue, objects)
|
||||
.then(clearFlushPromise, clearFlushPromise);
|
||||
|
Loading…
x
Reference in New Issue
Block a user