Return types of Results' Get method

Asked by Pieter Engelbrecht

I have a scope that currently has a bug that seems to be caused by what the `get` method of `results` returns.

I set an attribute of a card to an array value, and fetching it in the preview using result.get(<key>) seems to turn it into an object. So just want to confirm if this is the case?

PS. The reason this seems to be so is because when I want to iterate over the value using a forEach it shows that `forEach is not a function` and this happens only on a phone and not desktop. My specific bug is here (https://github.com/chesedo/glances-remote-scope/issues/1) if that may help.

Question information

Language:
English Edit question
Status:
Solved
For:
unity-js-scopes Edit question
Assignee:
No assignee Edit question
Solved by:
Marcus Tomlinson
Solved:
Last query:
Last reply:
Revision history for this message
Marcus Tomlinson (marcustomlinson) said :
#1

IF this is something that you see only on the phone and not the desktop, it would seem that you have an old version of unity-js-scopes being shipped with your scope.

Now and then the SDK will popup a message asking if you'd like to update your chroots. This is recommended as unity-js-scopes is quite an active project.

Could you try the following please:

1) Open the SDK, go to Tools->Options->Ubuntu, and click "Update" on the Vivid chroot.
    OR
        1) Run "unity-js-scopes-tool setup" on your desktop.
2) Remove the "src/node_modules/unity-js-scopes" folder from your scope.
3) Re-build the scope click package.
4) Try it on the phone again.

There was a fix recently for this precise issue: https://code.launchpad.net/~marcustomlinson/unity-js-scopes/lp-1541720/+merge/285032. From the commit message: "Do array check before object check in unity::scopesjs::to_variant() (arrays are also objects)."

Revision history for this message
Marcus Tomlinson (marcustomlinson) said :
#2

I'm terribly sorry! It seems that WE are the ones shipping an old version of the bindings. Please allow me to fix this, and I'll get back to you.

Revision history for this message
Pieter Engelbrecht (chesedo) said :
#3

Ah, thanks Marcus

Revision history for this message
Best Marcus Tomlinson (marcustomlinson) said :
#8

So, here's how we're gonna solve this issue (I'm really sorry for the runaround!):

Please follow these steps:

1) sudo add-apt-repository ppa:unity-api-team/unity-js-scopes
2) sudo apt update
3) sudo apt install unity-js-scopes-dev
4) unity-js-scopes-tool setup
5) Remove the "src/node_modules/unity-js-scopes" folder from your scope
6) Re-build the scope

That should do it.

(btw, the above is how we'll be asking everyone to install unity-js-scopes now: https://developer.ubuntu.com/en/scopes/tutorials/developing-scopes-javascript)

We are working to remove the need for a PPA at all, but unfortunately this is how it has to be for now. Thank you for your patience with us!

Revision history for this message
Pieter Engelbrecht (chesedo) said :
#9

Thanks Marcus, I am just waiting for the user to test and confirm that it works.

Will let you know soon.

Revision history for this message
Pieter Engelbrecht (chesedo) said :
#10

Thanks Marcus Tomlinson, that solved my question.