Skip to content

Commit

Permalink
Merge pull request #5174 from kobotoolbox/release-2.024.33-task-1165-…
Browse files Browse the repository at this point in the history
…project-header-title-bugfix

[TASK-1165] Fix project header title serving old asset name
  • Loading branch information
p2edwards authored Oct 18, 2024
2 parents 3ba0bad + 2e86349 commit 919b78b
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions jsapp/js/components/header/headerTitleEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ class HeaderTitleEditor extends React.Component<
}

componentDidMount() {
this.unlisteners.push(assetStore.listen(this.onAssetLoad, this));
// Note: there is a risk/vulnerability in this component connected to
// the usage of the `assetStore`. As `assetStore` is listening to
// `actions.resources.loadAsset` which is using our faulty `assetCache`,
// there is a chance `assetStore` would give us a cached (old) asset object.
this.unlisteners.push(assetStore.listen(this.onAssetStoreUpdated, this));
}

componentWillUnmount() {
Expand All @@ -45,11 +49,14 @@ class HeaderTitleEditor extends React.Component<
});
}

onAssetLoad() {
this.setState({
name: this.props.asset.name,
isPending: false,
});
onAssetStoreUpdated() {
const foundAsset = assetStore.getAsset(this.props.asset.uid);
if (foundAsset) {
this.setState({
name: foundAsset.name,
isPending: false,
});
}
}

updateAssetTitle() {
Expand Down

0 comments on commit 919b78b

Please sign in to comment.