Skip to content

Commit

Permalink
fix(saved icon): old UserHistory objects are from this form: {he: <ve…
Browse files Browse the repository at this point in the history
…rsionTitle>, en: <versionTitle>}, while new ones have the form of new currVersions with versionTitle and languageFamilyName. this commit change way we check if versions are same to feet both old and new.
  • Loading branch information
YishaiGlasner committed Jan 2, 2025
1 parent 6027ab7 commit 094af4a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions static/js/sefaria/sefaria.js
Original file line number Diff line number Diff line change
Expand Up @@ -2514,15 +2514,21 @@ _media: {},
// resolves to dictionary mapping ref to sugya ref
return this._ApiPromise(Sefaria.apiHost + "/api/passages/" + refs.join("|"));
},
areVersionsEqual(v1, v2) {
// v1, v2 are `currVersions` objects stored like {en: ven, he: vhe}
return v1?.en === v2?.en && v1?.he === v2?.he;
areVersionsEqual(savedVersion, currVersion) {
const checkEquality = (key) => {
//This is temporary for RTL - we check savedVersion?.[key] for old data and savedVersion?.[key]?.versionTitle for new data
//also we currently don't check the languageFamilyName to feet old data

This comment has been minimized.

Copy link
@akiva10b

akiva10b Jan 2, 2025

Contributor

to fit not feet unless you meant that this code is (רגליים לדבר) that we will forget to correct it

const savedVersionTitle = savedVersion?.[key]?.versionTitle || savedVersion?.[key] || '';
const currVersionTitle = currVersion?.[key]?.versionTitle || '';
return savedVersionTitle === currVersionTitle;
}
return checkEquality("en") && checkEquality("he");
},
getSavedItem: ({ ref, versions }) => {
return Sefaria.saved.items.find(s => s.ref === ref && Sefaria.areVersionsEqual(s.versions, versions));
},
removeSavedItem: ({ ref, versions }) => {
Sefaria.saved.items = Sefaria.saved.items.filter(x => !(x.ref === ref && Sefaria.areVersionsEqual(versions, x.versions)));
Sefaria.saved.items = Sefaria.saved.items.filter(x => !(x.ref === ref && Sefaria.areVersionsEqual(x.versions, versions)));
},
toggleSavedItem: ({ ref, versions, sheet_owner, sheet_title }) => {
return new Promise((resolve, reject) => {
Expand Down

0 comments on commit 094af4a

Please sign in to comment.