From f4a9bfac9f1c5c95879ec9c9b2f8a904cfe29728 Mon Sep 17 00:00:00 2001 From: Ben Wheeler <wheeler.benjamin@gmail.com> Date: Fri, 18 Oct 2019 13:41:20 -0400 Subject: [PATCH] in titledhoc, consolidate function calls --- src/lib/titled-hoc.jsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/lib/titled-hoc.jsx b/src/lib/titled-hoc.jsx index 30ed66217..b1d431aa9 100644 --- a/src/lib/titled-hoc.jsx +++ b/src/lib/titled-hoc.jsx @@ -21,11 +21,11 @@ const messages = defineMessages({ const TitledHOC = function (WrappedComponent) { class TitledComponent extends React.Component { componentDidMount () { - this.props.updateReduxProjectTitle(this.titleWithDefault(this.props.projectTitle)); + this.updateReduxProjectTitleWithDefault(this.props.projectTitle); } componentDidUpdate (prevProps) { if (this.props.projectTitle !== prevProps.projectTitle) { - this.props.updateReduxProjectTitle(this.titleWithDefault(this.props.projectTitle)); + this.updateReduxProjectTitleWithDefault(this.props.projectTitle); } // if the projectTitle hasn't changed, but the reduxProjectTitle // HAS changed, we need to report that change to the projectTitle's owner @@ -34,11 +34,12 @@ const TitledHOC = function (WrappedComponent) { this.props.onUpdateProjectTitle(this.props.reduxProjectTitle); } } - titleWithDefault (title) { - if (title === null || typeof title === 'undefined') { - return this.props.intl.formatMessage(messages.defaultProjectTitle); + updateReduxProjectTitleWithDefault (requestedTitle) { + let newTitle = requestedTitle; + if (newTitle === null || typeof newTitle === 'undefined') { + newTitle = this.props.intl.formatMessage(messages.defaultProjectTitle); } - return title; + this.props.updateReduxProjectTitle(newTitle); } render () { const { -- GitLab