From 75793f234c92c93ab743191fc11497533661a58c Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Tue, 11 Dec 2018 16:52:08 -0500 Subject: [PATCH] Editor: Reuse hook name across disparate hooks --- .../src/components/post-locked-modal/index.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/editor/src/components/post-locked-modal/index.js b/packages/editor/src/components/post-locked-modal/index.js index 39e5b3db16862e..e2f12e29aa00ec 100644 --- a/packages/editor/src/components/post-locked-modal/index.js +++ b/packages/editor/src/components/post-locked-modal/index.js @@ -30,19 +30,19 @@ class PostLockedModal extends Component { } componentDidMount() { - const hookNamePrefix = this.getHookNamePrefix(); + const hookName = this.getHookName(); // Details on these events on the Heartbeat API docs // https://developer.wordpress.org/plugins/javascript/heartbeat-api/ - addAction( 'heartbeat.send', hookNamePrefix + '-send', this.sendPostLock ); - addAction( 'heartbeat.tick', hookNamePrefix + '-tick', this.receivePostLock ); + addAction( 'heartbeat.send', hookName, this.sendPostLock ); + addAction( 'heartbeat.tick', hookName, this.receivePostLock ); } componentWillUnmount() { - const hookNamePrefix = this.getHookNamePrefix(); + const hookName = this.getHookName(); - removeAction( 'heartbeat.send', hookNamePrefix + '-send' ); - removeAction( 'heartbeat.tick', hookNamePrefix + '-tick' ); + removeAction( 'heartbeat.send', hookName ); + removeAction( 'heartbeat.tick', hookName ); } /** @@ -51,9 +51,9 @@ class PostLockedModal extends Component { * * @return {string} Hook name prefix. */ - getHookNamePrefix() { + getHookName() { const { instanceId } = this.props; - return 'core/editor/post-locked-modal-' + instanceId + '-heartbeat'; + return 'core/editor/post-locked-modal-' + instanceId; } /**