Lemmmy / KanjiSchool

Alternative web client for WaniKani
https://kanji.school
GNU Affero General Public License v3.0
16 stars 2 forks source link

Subject syncing broken #9

Closed slice closed 1 year ago

slice commented 1 year ago

As of 2023-06-21, KanjiSchool can't seem to sync subjects anymore. This happens when loading the database and when creating one from scratch. I suspect that this has to do with recent subjects added by Tofugu.

I get this error:

TypeError: Cannot set properties of undefined (setting 'ちょっと')
    at syncSubjects.ts:109:44
    at l (runtime.js:63:40)
    at Generator._invoke (runtime.js:293:22)
    at Generator.next (runtime.js:118:21)
    at r (asyncToGenerator.js:3:20)
    at c (asyncToGenerator.js:25:9)

I used DevTools to pause on the relevant line (slugCache[subject.object][subject.data.slug] = subject.id;), so I could see the contents of the subject variable:

{
    "id": 9176,
    "object": "kana_vocabulary",
    "url": "https://api.wanikani.com/v2/subjects/9176",
    "data_updated_at": "2023-06-21T08:12:23.392979Z",
    "data": {
        "created_at": "2022-09-14T11:39:10.684981Z",
        "level": 10,
        "slug": "ちょっと",
        "hidden_at": null,
        "document_url": "https://www.wanikani.com/vocabulary/%E3%81%A1%E3%82%87%E3%81%A3%E3%81%A8",
        "characters": "ちょっと",
        "meanings": [
            {
                "meaning": "A Little",
                "primary": true,
                "accepted_answer": true
            },
            {
                "meaning": "A Moment",
                "primary": false,
                "accepted_answer": true
            }
        ],
        "auxiliary_meanings": [
            {
                "type": "whitelist",
                "meaning": "A Bit"
            },
            {
                "type": "whitelist",
                "meaning": "A Few"
            },
            {
                "type": "whitelist",
                "meaning": "For A Moment"
            },
            {
                "type": "whitelist",
                "meaning": "A Minute"
            },
            {
                "type": "whitelist",
                "meaning": "For A Minute"
            },
            {
                "type": "whitelist",
                "meaning": "Some"
            }
        ],
        "parts_of_speech": [
            "adverb"
        ],
        "meaning_mnemonic": "You <reading>chort</reading>le (<ja>ちょっと</ja>) <vocabulary>a little</vocabulary> at a silly joke. You can’t help chortling for <vocabulary>for a moment</vocabulary>. Go ahead, chortle just a little, for just a moment, to help you remember this word.",
        "context_sentences": [
            {
                "en": "Oh, wait a moment!",
                "ja": "あ、ちょっとまって!"
            },
            {
                "en": "I think it's a little different.",
                "ja": "ちょっとちがう気がする。"
            },
            {
                "en": "I'll think about it a little.",
                "ja": "ちょっと考えてみるよ。"
            }
        ],
        "pronunciation_audios": [
            {
                "url": "https://files.wanikani.com/4zm5893mm9dnnxlafk7dgmsfij34",
                "metadata": {
                    "gender": "female",
                    "source_id": 44712,
                    "pronunciation": "ちょっと",
                    "voice_actor_id": 1,
                    "voice_actor_name": "Kyoko",
                    "voice_description": "Tokyo accent"
                },
                "content_type": "audio/webm"
            },
            {
                "url": "https://files.wanikani.com/asp3ls25zlp1uwk9e0ve84snccfv",
                "metadata": {
                    "gender": "female",
                    "source_id": 44712,
                    "pronunciation": "ちょっと",
                    "voice_actor_id": 1,
                    "voice_actor_name": "Kyoko",
                    "voice_description": "Tokyo accent"
                },
                "content_type": "audio/ogg"
            },
            {
                "url": "https://files.wanikani.com/hxahaewflbselg92c6g2l1bzwvj4",
                "metadata": {
                    "gender": "female",
                    "source_id": 44712,
                    "pronunciation": "ちょっと",
                    "voice_actor_id": 1,
                    "voice_actor_name": "Kyoko",
                    "voice_description": "Tokyo accent"
                },
                "content_type": "audio/mpeg"
            },
            {
                "url": "https://files.wanikani.com/n4ps1tzd3qso906dxewshfvezw3o",
                "metadata": {
                    "gender": "male",
                    "source_id": 44771,
                    "pronunciation": "ちょっと",
                    "voice_actor_id": 2,
                    "voice_actor_name": "Kenichi",
                    "voice_description": "Tokyo accent"
                },
                "content_type": "audio/webm"
            },
            {
                "url": "https://files.wanikani.com/kp83b9sep5qbxq0of2jhg1fhh37o",
                "metadata": {
                    "gender": "male",
                    "source_id": 44771,
                    "pronunciation": "ちょっと",
                    "voice_actor_id": 2,
                    "voice_actor_name": "Kenichi",
                    "voice_description": "Tokyo accent"
                },
                "content_type": "audio/ogg"
            },
            {
                "url": "https://files.wanikani.com/dqggbzm8faf7znf7ce133m2j849k",
                "metadata": {
                    "gender": "male",
                    "source_id": 44771,
                    "pronunciation": "ちょっと",
                    "voice_actor_id": 2,
                    "voice_actor_name": "Kenichi",
                    "voice_description": "Tokyo accent"
                },
                "content_type": "audio/mpeg"
            }
        ],
        "lesson_position": 55,
        "spaced_repetition_system_id": 1
    }
}

Hopefully this can be of use.

slice commented 1 year ago

Hmm, okay, looks like this is caused by a new kana_vocabulary subject type. KanjiSchool doesn't seem to know about it.

Lemmmy commented 1 year ago

Oh dear, yeah, I got an email about this a while ago so knew it was coming up but completely forgot to address it. Will look into this asap

Lemmmy commented 1 year ago

Thanks for the report! I've just pushed an update with basic support for kana vocabulary. The change was pretty invasive (KanjiSchool was very much built around the three 'radical', 'kanji' and 'vocabulary' primitives) but most things seem to work in basic testing. Please do let me know if you find anything strange with it, or any more crashes/errors.

The database should sort itself out automatically when you next force-reload KanjiSchool (Ctrl+Shift+R, or refresh, wait a minute, then refresh again).

I've also made the sync routine skip unknown subject types, so if WaniKani add any more new subject types in the future, it hopefully won't fail so catastrophically!

slice commented 1 year ago

@Lemmmy Thanks so much for the quick fix on this! 🙏🏼 I'll keep an eye out for any quirks or bugs.