sivenchinniah / Pokemanki

Other
58 stars 18 forks source link

message_handler should return original handled when not handling #44

Open BlueGreenMagick opened 3 years ago

BlueGreenMagick commented 3 years ago

I've been seeing a lot of unrecognized anki link: logs in the terminal when testing my other addon, and it turned out that I've made a mistake here :sweat_smile: This isn't anything critical though so please merge when you feel like it!

khonkhortisan commented 8 months ago

Pokemanki breaks Anki JavaScript API where I send 45 and receive false.

            print((True, {"error": None, "payload": ret}))
            return (True, {"error": None, "payload": ret})
pycmd("AnkiJS.ankiGetNewCardCount()",(ret) => {
    console.log("blue:");
    console.log(ret);
});
(True, {'error': None, 'payload': 45})
JS info :2 blue:
JS info :3 false

Of course this breaks, it's supposed to return handled https://github.com/ankitects/anki/blob/8fc4225b2965da81adcbd1687d0ff5a4d6ac2030/qt/tools/genhooks_gui.py#L670

    if not message.startswith("Pokemanki#"):
        return (False, None)

Merge this to fix compatibility with Anki Javascript API