@wordpress/core-data
Version:
Access to and manipulation of core WordPress entities.
35 lines (34 loc) • 817 B
JavaScript
// packages/core-data/src/locks/selectors.js
import {
iterateDescendants,
iteratePath,
hasConflictingLock,
getNode
} from "./utils";
function getPendingLockRequests(state) {
return state.requests;
}
function isLockAvailable(state, store, path, { exclusive }) {
const storePath = [store, ...path];
const locks = state.tree;
for (const node2 of iteratePath(locks, storePath)) {
if (hasConflictingLock({ exclusive }, node2.locks)) {
return false;
}
}
const node = getNode(locks, storePath);
if (!node) {
return true;
}
for (const descendant of iterateDescendants(node)) {
if (hasConflictingLock({ exclusive }, descendant.locks)) {
return false;
}
}
return true;
}
export {
getPendingLockRequests,
isLockAvailable
};
//# sourceMappingURL=selectors.js.map