From 4369d93f283f5203ad4a91ad04cce015b2699654 Mon Sep 17 00:00:00 2001 From: Christian Glingener <1089098+CGlingener@users.noreply.github.com> Date: Thu, 8 Nov 2018 22:03:20 +0100 Subject: [PATCH] Fix save lock control (length check on object) (#11636) * Fix length check on object * Editor: Correct state shape of tested post saving lock --- packages/editor/src/store/selectors.js | 2 +- packages/editor/src/store/test/selectors.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/editor/src/store/selectors.js b/packages/editor/src/store/selectors.js index 783a0ee72d39af..81fa98f7fab2fc 100644 --- a/packages/editor/src/store/selectors.js +++ b/packages/editor/src/store/selectors.js @@ -2100,7 +2100,7 @@ export function isPostLocked( state ) { * @return {boolean} Is locked. */ export function isPostSavingLocked( state ) { - return state.postSavingLock.length > 0; + return Object.keys( state.postSavingLock ).length > 0; } /** diff --git a/packages/editor/src/store/test/selectors.js b/packages/editor/src/store/test/selectors.js index 58a839ff93a471..1470f2261db39c 100644 --- a/packages/editor/src/store/test/selectors.js +++ b/packages/editor/src/store/test/selectors.js @@ -1098,7 +1098,7 @@ describe( 'selectors', () => { describe( 'isPostSavingLocked', () => { it( 'should return true if the post has postSavingLocks', () => { const state = { - postSavingLock: [ { 1: true } ], + postSavingLock: { example: true }, currentPost: {}, saving: {}, }; @@ -1108,7 +1108,7 @@ describe( 'selectors', () => { it( 'should return false if the post has no postSavingLocks', () => { const state = { - postSavingLock: [], + postSavingLock: {}, currentPost: {}, saving: {}, };