From 838f78fda82c326205a34a888f5c6d90889c2e88 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Sun, 7 Jan 2018 10:17:10 -0500 Subject: [PATCH] Clean up code for getCompareString --- editor/utils/heartbeat.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/editor/utils/heartbeat.js b/editor/utils/heartbeat.js index d32ac50fd6715..b33abc3871f3e 100644 --- a/editor/utils/heartbeat.js +++ b/editor/utils/heartbeat.js @@ -9,6 +9,8 @@ import { toggleAutosave, } from '../store/actions'; +import { compact } from 'lodash'; + /** * WordPress dependencies */ @@ -29,7 +31,7 @@ export function setupHeartbeat() { } ); /** - * @summary Concatenates the title, content and excerpt. + * Concatenate the title, content and excerpt. * * This is used to track changes when auto-saving. * @@ -40,7 +42,11 @@ export function setupHeartbeat() { * @returns {string} A concatenated string with title, content and excerpt. */ const getCompareString = function( state ) { - return ( getEditedPostTitle( state ) || '' ) + '::' + ( getEditedPostContent( state ) || '' ) + '::' + ( getEditedPostExcerpt( state ) || '' ); + return compact( [ + getEditedPostTitle( state ), + getEditedPostContent( state ), + getEditedPostExcerpt( state ), + ] ).join( '::' ); }; /**