Skip to content

Commit

Permalink
Revert "chore: if editor changes collections, show immediately in Par…
Browse files Browse the repository at this point in the history
…tOfCollections"

This reverts commit 1b24ed0.
  • Loading branch information
stevekaplan123 committed Dec 15, 2024
1 parent 1b24ed0 commit 5fdf37d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 40 deletions.
51 changes: 19 additions & 32 deletions static/js/sheets/Sheet.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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))) {
Expand All @@ -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) {
Expand All @@ -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 = <SheetContentSidebar
authorStatement={sheet.ownerName}
authorUrl={sheet.ownerProfileUrl}
Expand Down Expand Up @@ -142,21 +129,21 @@ class Sheet extends Component {
handleClick={this.handleClick}
sheetSourceClick={this.props.onSegmentClick}
highlightedNode={this.props.highlightedNode} // for example, "3" -- the third node in the sheet
highlightedRefs={this.props.highlightedRefs} // for example, ["Genesis 1:1"] or ["sheet 4:3"] -- the actual source
highlightedRefsInSheet={this.props.highlightedRefsInSheet}
scrollToHighlighted={this.props.scrollToHighlighted}
editable={editable}
setSelectedWords={this.props.setSelectedWords}
sheetNumbered={sheet.options.numbered}
hideImages={!!sheet.hideImages}
sheetID={sheet.id}
authorStatement={sheet.ownerName}
authorID={sheet.owner}
authorUrl={sheet.ownerProfileUrl}
authorImage={sheet.ownerImageUrl}
summary={sheet.summary}
toggleSignUpModal={this.props.toggleSignUpModal}
historyObject={this.props.historyObject}
highlightedRefs={this.props.highlightedRefs} // for example, ["Genesis 1:1"] or ["Sheet 4:3"] -- the actual source
highlightedRefsInSheet={this.props.highlightedRefsInSheet}
scrollToHighlighted={this.props.scrollToHighlighted}
editable={editable}
setSelectedWords={this.props.setSelectedWords}
sheetNumbered={sheet.options.numbered}
hideImages={!!sheet.hideImages}
sheetID={sheet.id}
authorStatement={sheet.ownerName}
authorID={sheet.owner}
authorUrl={sheet.ownerProfileUrl}
authorImage={sheet.ownerImageUrl}
summary={sheet.summary}
toggleSignUpModal={this.props.toggleSignUpModal}
historyObject={this.props.historyObject}
/>
{sidebar}
</div>
Expand Down
13 changes: 5 additions & 8 deletions static/js/sheets/SheetOptions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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
Expand Down Expand Up @@ -56,11 +57,7 @@ const SheetOptions = ({historyObject, toggleSignUpModal, sheetID, editable, auth
return <ShareModal sheetID={sheetID} isOpen={sharingMode} close={() => setSharingMode(false)}/>;
}
else if (collectionsMode) {
return <CollectionsModal
isOpen={collectionsMode}
close={() => setCollectionsMode(false)}
handleCollectionsChange={handleCollectionsChange}
sheetID={sheetID}/>;
return <CollectionsModal isOpen={collectionsMode} close={() => setCollectionsMode(false)} sheetID={sheetID}/>;
}
else if (copyingMode) {
return <CopyModal close={() => setCopyingMode(false)} sheetID={sheetID}/>;
Expand Down Expand Up @@ -145,9 +142,9 @@ const ShareModal = ({sheetID, close}) => {
/>
</Modal>;
}
const CollectionsModal = ({close, sheetID, handleCollectionsChange, editable}) => {
const CollectionsModal = ({close, sheetID}) => {
return <Modal isOpen={true} close={close}>
<CollectionsWidget sheetID={sheetID} close={close} handleCollectionsChange={handleCollectionsChange} />
<CollectionsWidget sheetID={sheetID} close={close} />
</Modal>;
}

Expand Down

0 comments on commit 5fdf37d

Please sign in to comment.