diff --git a/static/js/sheets/Sheet.jsx b/static/js/sheets/Sheet.jsx index 1cc6a1d075..55b64289e6 100644 --- a/static/js/sheets/Sheet.jsx +++ b/static/js/sheets/Sheet.jsx @@ -64,7 +64,7 @@ class Sheet extends Component { if (path.match(/^\/sheets\/\d+/)) { e.preventDefault() console.log(); - this.props.onCitationClick(`Sheet ${path.slice(8)}`, `Sheet ${this.props.id}`, true) + this.props.onCitationClick(`Sheet ${path.slice(8)}`, `Sheet ${this.props.sheetID}`, true) } else if (Sefaria.isRef(path.slice(1))) { @@ -73,23 +73,11 @@ 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(); - }); - } + render() { - const classes = classNames({sheetsInPanel: 1}); const sheet = this.getSheetFromCache(); + const classes = classNames({sheetsInPanel: 1}); const editable = Sefaria._uid === sheet?.owner; let content, editor; if (!sheet) { @@ -101,8 +89,7 @@ class Sheet extends Component { sheetID={sheet.id} historyObject={this.props.historyObject} editable={editable} - authorUrl={sheet.ownerProfileUrl} - handleCollectionsChange={editable && this.handleCollectionsChange}/>; + authorUrl={sheet.ownerProfileUrl}/>; const sidebar = {sidebar} diff --git a/static/js/sheets/SheetOptions.jsx b/static/js/sheets/SheetOptions.jsx index b07932ddab..0171766d8a 100644 --- a/static/js/sheets/SheetOptions.jsx +++ b/static/js/sheets/SheetOptions.jsx @@ -4,6 +4,7 @@ import {InterfaceText, SaveButtonWithText} from "../Misc"; import Modal from "../common/modal"; import {ShareBox} from "../ConnectionsPanel"; import Sefaria from "../sefaria/sefaria"; +import $ from "../sefaria/sefariaJquery"; import {SignUpModalKind} from "../sefaria/signupModalContent"; import {AddToSourceSheetBox} from "../AddToSourceSheet"; import {CollectionsWidget} from "../CollectionsWidget"; @@ -20,7 +21,7 @@ const getExportingStatus = () => { return urlHashObject === "exportToDrive"; } -const SheetOptions = ({historyObject, toggleSignUpModal, sheetID, editable, authorUrl, handleCollectionsChange}) => { +const SheetOptions = ({historyObject, toggleSignUpModal, sheetID, editable, authorUrl}) => { // `editable` -- whether the sheet belongs to the current user const [sharingMode, setSharingMode] = useState(false); // Share Modal open or closed const [collectionsMode, setCollectionsMode] = useState(false); // Collections Modal open or closed @@ -56,11 +57,7 @@ const SheetOptions = ({historyObject, toggleSignUpModal, sheetID, editable, auth return setSharingMode(false)}/>; } else if (collectionsMode) { - return setCollectionsMode(false)} - handleCollectionsChange={handleCollectionsChange} - sheetID={sheetID}/>; + return setCollectionsMode(false)} sheetID={sheetID}/>; } else if (copyingMode) { return setCopyingMode(false)} sheetID={sheetID}/>; @@ -145,9 +142,9 @@ const ShareModal = ({sheetID, close}) => { /> ; } -const CollectionsModal = ({close, sheetID, handleCollectionsChange, editable}) => { +const CollectionsModal = ({close, sheetID}) => { return - + ; }