Skip to content

Commit 8e1b6be

Browse files
authored
Merge pull request #290 from scratchfoundation/fix/unnecessary-title-updates
[IPR-979] Omit multiple unnecessary project title update calls
2 parents 0a42273 + 2ee5129 commit 8e1b6be

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

packages/scratch-gui/src/lib/titled-hoc.jsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@ const TitledHOC = function (WrappedComponent) {
3131
this.handleReceivedProjectTitle(this.props.projectTitle);
3232
}
3333
// if project is a new default project, and has loaded,
34-
if (this.props.isShowingWithoutId && prevProps.isAnyCreatingNewState) {
34+
if (this.props.isShowingWithoutId && !this.props.isAnyCreatingNewState && prevProps.isAnyCreatingNewState) {
3535
// reset title to default
36-
const defaultProjectTitle = this.handleReceivedProjectTitle();
37-
this.props.onUpdateProjectTitle(defaultProjectTitle);
36+
this.handleReceivedProjectTitle();
3837
}
3938
// if the projectTitle hasn't changed, but the reduxProjectTitle
4039
// HAS changed, we need to report that change to the projectTitle's owner
41-
if (this.props.reduxProjectTitle !== prevProps.reduxProjectTitle &&
40+
if (!this.props.isShowingWithoutId &&
41+
!this.props.isAnyCreatingNewState &&
42+
this.props.reduxProjectTitle !== prevProps.reduxProjectTitle &&
4243
this.props.reduxProjectTitle !== this.props.projectTitle) {
4344
this.props.onUpdateProjectTitle(this.props.reduxProjectTitle);
4445
}

0 commit comments

Comments
 (0)