Skip to content

Commit

Permalink
fix project header title serving old asset name
Browse files Browse the repository at this point in the history
  • Loading branch information
magicznyleszek committed Oct 16, 2024
1 parent 941b886 commit 2e86349
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 2e86349

Please sign in to comment.