Content-Length: 367379 | pFad | http://github.com/Sefaria/Sefaria-Project/pull/2381

A8 Bug/sc 520/second try by stevekaplan123 · Pull Request #2381 · Sefaria/Sefaria-Project · GitHub
Skip to content

Bug/sc 520/second try #2381

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

Merged
merged 10 commits into from
May 18, 2025
Merged

Bug/sc 520/second try #2381

merged 10 commits into from
May 18, 2025

Conversation

stevekaplan123
Copy link
Contributor

@stevekaplan123 stevekaplan123 commented Mar 11, 2025

Description

In this PR, I fixed two bugs. For most cases, such as Rashi, we were only making one API call to the section ref, but it was the wrong section ref. For some cases, like Malbim Ayelet HaShachar, we were making hundreds of unnecessary API calls.

Code Changes

  1. Before implementing a fix, I re-factored the TextList component somewhat, which renders the comments in the Connections Panel. First of all, the links displayed in the TextList are now part of the component's state. Previously, we calculated it each render. Second, we used to handle changing the Connections Panel filter ("Rashi" to "Ibn Ezra") in one way and handle clicking on a different segment in the reader in a different way, but I felt it was simpler to handle them together. Now, when the filter or ref is changed, we call loadConnections. Here's how my approach works -- Suppose the reader panel is at "Genesis 3:2" and the filter is "Rashi":
    (a) First, loadConnections calls the related API to make sure we have all the links for the "Genesis 3" (or grab the cached result if we've already called the related API for "Genesis 3" before)
    (b) Second, filter the links returned by the related API/cache as we only want to display links that are connected to "Rashi on Genesis 3:2"
    (c) Finally, if the connections panel filter is a commentary, as it is in the case of Rashi, preload the commentary section ref text, which in this case is the text for "Rashi on Genesis 3:2". This last step speeds things up because if the user were to click on any of the comments in "Rashi on Genesis 3:2", some of the data is now there and less API calls need to be made. I believe the reason we only preload in the case of a commentary is because we assume it is much more likely to be opened by a user than a link to Talmud, Midrash, etc.

  2. Previously, preloadText dealt with two cases: (a) when the filter was a single commentary and (b) when the filter was all commentaries at once. I removed case (b) because it can't possibly benefit us to call the text API for many commentaries when the user may not even open any of them. Moreover, I re-factored the single commentary case so that now:
    (a) It uses the new v3 text API to retrieve the text.
    (b) Previously, we derived the commentary ref to retrieve incorrectly. We would take a segment ref "Rashi on Genesis 1:3:5" and call the text API for the ref "Rashi on Genesis 1". This is useless as we never try to access "Rashi on Genesis 1" in the cache. Instead, when the user clicks "Open" on a link "Rashi on Genesis 1:3:5", we do try to access the cache for "Rashi on Genesis 1:3". I use the Sefaria.zoomOutRef to "zoom out" from "Rashi on Genesis 1:3:5" to "Rashi on Genesis 1:3" so that we call the API on the appropriate ref.

@stevekaplan123 stevekaplan123 requested a review from Copilot March 11, 2025 12:10
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR, titled "Bug/sc 520/second try", refactors text loading and connection preloading in TextList.jsx while also removing an unused commentary helper from sefaria.js.

  • Refactored state management in TextList.jsx to include a dedicated "links" state and merge filter update checks into componentDidUpdate.
  • Replaced the deprecated componentWillReceiveProps with a combined condition in componentDidUpdate and updated the text preloading logic.
  • Removed the commentarySectionRef function from sefaria.js to simplify the API.

Reviewed Changes

File Description
static/js/TextList.jsx Refactored connection loading and commentary text preloading methods with updated state logic.
static/js/sefaria/sefaria.js Removed the commentarySectionRef function to streamline the API.

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

static/js/sefaria/sefaria.js:1785

  • The complete removal of commentarySectionRef may cause issues if any other parts of the codebase expect this function to exist. Verify that all dependent code has been updated to reflect its removal.
commentarySectionRef: function(commentator, baseRef) { … }

@stevekaplan123 stevekaplan123 changed the base branch from bug/sc-25530/current-place-in-toc-not-displaying-properly to master March 11, 2025 14:05
@stevekaplan123 stevekaplan123 marked this pull request as ready for review March 31, 2025 19:01
@stevekaplan123 stevekaplan123 marked this pull request as draft March 31, 2025 19:01
@coolify-sefaria
Copy link

coolify-sefaria bot commented Apr 3, 2025

The preview deployment is ready. 🟢

Open Build Logs

Last updated at: 2025-04-06 12:33:02 CET

@stevekaplan123 stevekaplan123 marked this pull request as ready for review April 8, 2025 11:21
@stevekaplan123 stevekaplan123 requested a review from yitzhakc April 9, 2025 08:16
@stevekaplan123
Copy link
Contributor Author

@yitzhakc I fixed the only thing remaining -- the broken commentary button. It was due to one line of code which I changed in the latest commit.

@yitzhakc yitzhakc added this pull request to the merge queue May 11, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 11, 2025
@stevekaplan123 stevekaplan123 added this pull request to the merge queue May 11, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 11, 2025
@stevekaplan123
Copy link
Contributor Author

@yitzhakc Not merging due to playwright tests. Can you override it? Thanks!

@yitzhakc yitzhakc merged commit 8d19b44 into master May 18, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/Sefaria/Sefaria-Project/pull/2381

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy