Skip to content

Commit

Permalink
chore: pass handleCollectionsChange from Sheet to Editor to SheetOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
stevekaplan123 committed Dec 15, 2024
1 parent 368aba4 commit 57ae1dc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
3 changes: 2 additions & 1 deletion static/js/Editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2955,9 +2955,10 @@ const SefariaEditor = (props) => {
sheetID={sheet.id}
postSheet={postSheet}
historyObject={props.historyObject}
editable={props.editable}
editable={true}
authorUrl={sheet.ownerProfileUrl}
status={status}
handleCollectionsChange={props.handleCollectionsChange}
/>;
return (
<div ref={editorContainer} onClick={props.handleClick} className="text">
Expand Down
18 changes: 6 additions & 12 deletions static/js/sheets/Sheet.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,10 @@ class Sheet extends Component {
}
}
handleCollectionsChange() {
// when editing a sheet and user selects through SheetOptions to change the status of the collections for the sheet,
// update the user's collections and sheet cache. need to forceUpdate because sheet is stored not in this component's state
// but rather in Sefaria module's cache
Promise.all([
Sefaria.getUserCollections(Sefaria._uid),
Sefaria.getUserCollectionsForSheet(this.props.id)
])
.then(() => {
Sefaria.sheets._loadSheetByID[this.props.id].collections = Sefaria.getUserCollectionsForSheetFromCache(this.props.id);
this.forceUpdate();
});
// when editing a sheet and user makes (through SheetOptions) a change in sheet's collections data we need to forceUpdate because
// sheet is stored not in this component's state but rather in Sefaria module's cache
Sefaria.sheets._loadSheetByID[this.props.id].collections = Sefaria.getUserCollectionsForSheetFromCache(this.props.id);
this.forceUpdate();
}

render() {
Expand Down Expand Up @@ -117,7 +110,8 @@ class Sheet extends Component {
divineNameReplacement={this.props.divineNameReplacement}
toggleSignUpModal={this.props.toggleSignUpModal}
historyObject={this.props.historyObject}
editable={editable}
editable={true}
handleCollectionsChange={this.handleCollectionsChange}
/>
</div>
{sidebar}
Expand Down

0 comments on commit 57ae1dc

Please sign in to comment.