ToranSharma / Duo-Strength

Browser extension to add back the strength for each individual skill, and other useful hidden statistics.
MIT License
35 stars 6 forks source link

Uncaught (in promise) TypeError - skills needed strengthening #156

Closed alexseyk closed 3 years ago

alexseyk commented 3 years ago

L0 Ingles de Español árbol in Yandex Browser, error is generated when enabling / disabling display of skills needed strengthening.

Discovered as part of the original problem - retry buttons not displayed on the completed checkpoints , also practice at L0 skill button not displayed and "key" on the GS too :( . All options are enabled and works at least on Spanish tree.

duoStrength.js:2756 Uncaught (in promise) TypeError: Cannot read property 'short' of undefined at createOpenPopoutButton (duoStrength.js:2756) at displayNeedsStrengthening (duoStrength.js:2018) at addFeatures (duoStrength.js:4254) at duoStrength.js:4612 at new Promise () at requestData (duoStrength.js:4606) at init (duoStrength.js:5663)

duoStrength.js:2756 Uncaught (in promise) TypeError: Cannot read property 'short' of undefined at createOpenPopoutButton (duoStrength.js:2756) at displayNeedsStrengthening (duoStrength.js:2018) at addFeatures (duoStrength.js:4254) at handleDataResponse (duoStrength.js:4598)

ToranSharma commented 3 years ago

I don't seem to be getting that error on my L0 es->en tree. The error is saying that it cannot find the first skill in the needs strengthening list in the userData file's list of skills based off of the url in the link in the needs strengthening list.

The needs strengthening list should be displayed despite this error. Which skills are in it, and could you show me the link address of the first skill.

ToranSharma commented 3 years ago

I think it likely that this is also what is happening in #150. Given the cracked skills list is added after the needs strengthening, so if an error occurs in that, the execution stops and the cracked skills list won't be displayed. If you toggle the display of the needs needs strengthening list the cracked skills list will be added, followed by the needs strengthening with the error then stopping everything after that, but the cracked skills list is already there.

alexseyk commented 3 years ago

I don't have cracked skills, as it is on my 2nd (test) account. However toggling display of cracked skills and suggested skills generates a lot of the same errors, Also even that Hide option selected in the suggested skills, it is ignored . In the Strengthening I have reveres order.

Your tree has 8 skills that need strengthening: Religión, Palabras 9, Recreo, Palabras 8, Gente 4, Palabras 7, Pasado 4 & Cuidado

https://www.duolingo.com/skill/en/Religión/practice

Most likely the bug is due to the special character ó & etc

ToranSharma commented 3 years ago

Thanks for the info, special characters were my leading theory. Should be a fairly easy fix.

On Thu, 4 Mar 2021, 14:34 Alex, notifications@github.com wrote:

I don't have cracked skills, as it is on my 2nd (test) account. However toggling display of cracked skills and suggested skills generates a lot of the same errors, Also even that Hide option selected in the suggested skills, it is ignored . In the Strengthening I have reveres order.

Your tree has 8 skills that need strengthening: Religión, Palabras 9, Recreo, Palabras 8, Gente 4, Palabras 7, Pasado 4 & Cuidado

https://www.duolingo.com/skill/en/Religión/practice

Most likely the bug is due to the special character ó & etc

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ToranSharma/Duo-Strength/issues/156#issuecomment-790661509, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABCZIYFTRYUKPNXJOXPRADDTB6LA5ANCNFSM4YTB4DEQ .

ToranSharma commented 3 years ago

Yeah, I can reproduce the issue on my es->en tree with the code:

displayNeedsStrengthening([[userData.language_data.en.skills[189]],[]]);

The line

const firstSkillUrlTitle = firstSkillLink.href.match(new RegExp(`/${languageCode}/([^/]*)`))[1];
// gives the encoded:
"Religi%C3%B3n"
// Rather than
"Religión"
// Which then doesn't match any skills in the userData

Wrapping all instances of getting the skill's url_title from the link in decodeURIComponent( ... ) fixes the issue.

This has been changed in 2ff5050.