Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #510

Merged
merged 3 commits into from
Feb 4, 2025
Merged

Dev #510

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions static/js/TextList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@ class TextList extends Component {
this.preloadSingleCommentaryText(filter);

} else if (filter.length == 1 && filter[0] == "Commentary") {

this.preloadAllCommentaryText(filter);

} else {
this.setState({waitForText: false, textLoaded: false});
this.setState({waitForText: false, textLoaded: true});
}
}
preloadSingleCommentaryText(filter) {
Expand All @@ -95,15 +96,14 @@ class TextList extends Component {
var commentator = filter[0];
var basetext = this.getSectionRef();
var commentarySection = Sefaria.commentarySectionRef(commentator, basetext);
console.log("commentary text,, ", commentator, basetext, commentarySection);
if (!commentarySection) {
this.setState({waitForText: false});
return;
}
this.setState({waitForText: true});
Sefaria.text(commentarySection, {}, function() {
if (this._isMounted) {
this.setState({textLoaded: true});
this.setState({textLoaded: false});
}
}.bind(this));
}
Expand All @@ -118,38 +118,38 @@ class TextList extends Component {
});

if (commentators.length) {

var commentarySections = commentators.map(function(commentator) {

return Sefaria.commentarySectionRef(commentator, basetext);
}).filter(function(commentarySection) {
return !!commentarySection;
});
this.waitingFor = Sefaria.util.clone(commentarySections);

this.target = 0;
for (var i = 0; i < commentarySections.length; i++) {
Sefaria.text(commentarySections[i], {}, function(data) {
var index = this.waitingFor.indexOf(data.commentator);
if (index == -1) {
// console.log("Failed to clear commentator:");
// console.log(data);
this.target += 1;
}
if (index > -1) {
this.waitingFor.splice(index, 1);
}
if (this.waitingFor.length == this.target) {
if (this._isMounted) {
this.setState({textLoaded: true});
}
if (this._isMounted ) {
this.setState({textLoaded: false})
}
}.bind(this));
}
} else {
// All commentaries have been loaded already
this.setState({textLoaded: true});
this.setState({textLoaded: false});
}
} else {
// There were no commentaries to load
this.setState({textLoaded: true});
this.setState({textLoaded: false});
}
}
getLinks() {
Expand Down Expand Up @@ -199,7 +199,9 @@ class TextList extends Component {
var filter = this.props.filter; // Remove filterSuffix for display
var displayFilter = filter.map(filter => filter.split("|")[0]); // Remove filterSuffix for display
var links = this.getLinks();
var isComplexText = Sefaria.normRef(oref).isComplex

var loadingState = isComplexText ? this.state.textLoaded : !this.state.textLoaded
// this.state.waitForText && !this.state.textLoaded
var enText = filter.length ? displayFilter.join(", "): ""
var en = Sefaria._('text.message.no_connection', {text: enText});
Expand All @@ -208,7 +210,7 @@ class TextList extends Component {
var noResultsMessage = <LoadingMessage message={en} heMessage={he} />;
var message = !this.state.linksLoaded ? (<LoadingMessage />) : (links.length === 0 ? noResultsMessage : null);
var content = links.length === 0 ? message :
this.state.waitForText && this.state.textLoaded ?
this.state.textLoaded ?
(<LoadingMessage />) :
links.map(function(link, i) {
if (link.isSheet) {
Expand Down