Skip to content

Commit

Permalink
Clean up code for getCompareString
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Silverstein committed Jan 7, 2018
1 parent 1ee973e commit 838f78f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions editor/utils/heartbeat.js
Expand Up @@ -9,6 +9,8 @@ import {
toggleAutosave,
} from '../store/actions';

import { compact } from 'lodash';

/**
* WordPress dependencies
*/
Expand All @@ -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.
*
Expand All @@ -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( '::' );
};

/**
Expand Down

0 comments on commit 838f78f

Please sign in to comment.