I am writing a gmail contextual gadget. Having traversed this minefield I am stuck on an issue no one else seems to have, my UserPreferences only save on page refresh, if I simply navigate back to the inbox and to another email they are forgotten. I have the user prefs enabled:

<Require feature="setprefs"/>

They look like this:

<UserPref name="enabled"
    datatype="hidden"
    default_value="true">
</UserPref>

I have tried initializing my prefs with and without the module id:

var prefs = new gadgets.Prefs();

or

var prefs = new gadgets.Prefs(__MODULE_ID__);

I even forced a refresh with javascipt on the iframe/gadget and that didn't work either, making me believe that the issue is with google caching the old data for me and not saving it until the page is closed, if that makes any sense.

And I am using /?nogadgetcache=1/ in my url

有帮助吗?

解决方案

Well I'm not expecting an answer so here is my solution for anyone else coming across this:

Google does indeed cache all data for UserPrefs while navigating through inbox, sent, trash, individual mails etc.

As UserPrefs are saved they are sent to Google's server correctly, but the last pull will remain in cache, so there is no way around a refresh. I reduced my use of UserPrefs except where necessary, and informed the user politely to refresh to see changes take effect.

There is no documentation on this and maybe Google will change this in future, so if anyone finds a solution please do post it here for the community's sake. Thanks

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top