mockturtl / cinnamon-weather

DEPRECATED. Use linuxmint/cinnamon-spices-applets instead.
https://cinnamon-spices.linuxmint.com/applets/view/17
28 stars 35 forks source link

Weather data doesn't load until commenting out try-catch block in MyApplet.refreshWeather #177

Closed jaszhix closed 7 years ago

jaszhix commented 7 years ago

Linux Mint 18.1 Cinnamon 3.2.7 Weather 1.13.7

For some reason the applet only loads once on a fresh boot. If I restart Cinnamon or the applet, the http request never completes. When I comment out this try-catch block, it works every time. I can see this might not be an issue if someone never restarts Cinnamon, but I think there must be a way to debug this. I see this in glass.log a lot every day:

error t=2017-01-01T18:08:03.469Z weather@mockturtl#: TypeError: json.get_object_member(...).get_object_member(...) is null

It seems like we could replace this with JSON.parse and have native formatting of the weather object. It would require rewriting all the lines accessing the object but would be a lot easier to read and debug.

When I import Main and add Main._logInfo(message.response_body.data) on L370, I see

error t=2017-01-01T18:16:47.458Z weather@mockturtl#: TypeError: json.get_object_member(...).get_object_member(...) is null
info t=2017-01-01T18:17:30.414Z {"query":{"count":0,"created":"2017-01-01T18:17:30Z","lang":"en-US","results":null}}

So maybe when results is null, we could recurse the object for x amount of times, checking its value. I'm not sure why the request would return null, but I'm guessing its Soup's fault. I found this, which also might be useful.

sdgathman commented 7 years ago

Using native parsing would effectively run code from an untrusted source (yahoo). Do you really want yahoo running arbitrary javascript code in your cinnamon desktop?

jaszhix commented 7 years ago

I don't. Fortunately, that has nothing to do with this issue, nor is it possible as CJS can't run browser JS without modification.

Edit: Here's the MDN documentation for JSON.parse, it does everything Soup's seemingly pointless abstraction does, but more concisely. You may be confusing this with eval.

mockturtl commented 7 years ago

Hello,

This issue is being closed because development is moving to linuxmint/cinnamon-spices/applets. Feel free to reopen your issue there.

Please see the release announcement here:

http://segfault.linuxmint.com/2017/01/changes-to-cinnamon-spices-for-developer-and-artists/