{"action":"created","issue":{"url":"https://api.github.com/repos/c9/core/issues/268","repository_url":"https://api.github.com/repos/c9/core","labels_url":"https://api.github.com/repos/c9/core/issues/268/labels{/name}","comments_url":"https://api.github.com/repos/c9/core/issues/268/comments","events_url":"https://api.github.com/repos/c9/core/issues/268/events","html_url":"https://github.com/c9/core/pull/268","id":139795978,"number":268,"title":"Reverted proposeLayoutChange, added resetTheme to API","user":{"login":"dmalan","id":788678,"avatar_url":"https://avatars.githubusercontent.com/u/788678?v=3","gravatar_id":"","url":"https://api.github.com/users/dmalan","html_url":"https://github.com/dmalan","followers_url":"https://api.github.com/users/dmalan/followers","following_url":"https://api.github.com/users/dmalan/following{/other_user}","gists_url":"https://api.github.com/users/dmalan/gists{/gist_id}","starred_url":"https://api.github.com/users/dmalan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmalan/subscriptions","organizations_url":"https://api.github.com/users/dmalan/orgs","repos_url":"https://api.github.com/users/dmalan/repos","events_url":"https://api.github.com/users/dmalan/events{/privacy}","received_events_url":"https://api.github.com/users/dmalan/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-10T06:07:36Z","updated_at":"2016-03-16T19:27:48Z","closed_at":"2016-03-16T19:27:48Z","pull_request":{"url":"https://api.github.com/repos/c9/core/pulls/268","html_url":"https://github.com/c9/core/pull/268","diff_url":"https://github.com/c9/core/pull/268.diff","patch_url":"https://github.com/c9/core/pull/268.patch"},"body":"This commit reverts [yesterday's change](https://github.com/c9/core/pull/266) to `proposeLayoutChange`, which added a `reset` parameter to that function in order to provide the caller with the ability to squelch the **Would you like to reset colors to their default value?** dialog. Wasn't necessarily a bad addition, but we realized that calling `proposeLayoutChange` with a value of `true` for `force` doesn't yield the best UX anyway, since it overrides that dialog's `showDontAsk` checkbox, even if the user has checked it previously (which a user would likely feel is a bug).\r\n\r\nThis PR instead proposes the addition of a `resetTheme` API method that would allow a caller to induce a theme change without prompting the user. (The intended use case is implementation of a button that toggles between day and night themes.)\r\n\r\nOriginally, we implemented `resetTheme` as a setter for `theme` (complementing the existing getter for `theme`), but doing so revealed a potential race condition:\r\n\r\n1. A caller calls `settings.on(\"user/general/@skin\", f);`.\r\n1. A caller sets theme with `imports.layout.theme = theme;`.\r\n1. Our setter calls `settings.set(\"user/general/@skin\", theme);`.\r\n1. `f` gets invoked and tries to access the new theme via `imports.layout.theme`, the getter, but `theme` is only set once `updateTheme` is called.\r\n1. Our setter calls `updateTheme` (too late).\r\n\r\nTo avoid that scenario altogether, it seemed safest not to implement the setter. \r\n\r\nThough this potential for race conditions does seem to be an inherent side effect of using `settings.set` (a la an API call) to set keys like `user/general/@skin`, which are allowed to have onchange listeners, even though those keys are thus set *before* the underlying state (`imports.layout.theme` in this case) is updated? Seemed best not to stray from that design pattern with this particular commit, though!\r\n\r\nCC @danallan "},"comment":{"url":"https://api.github.com/repos/c9/core/issues/comments/197502716","html_url":"https://github.com/c9/core/pull/268#issuecomment-197502716","issue_url":"https://api.github.com/repos/c9/core/issues/268","id":197502716,"user":{"login":"nightwing","id":341801,"avatar_url":"https://avatars.githubusercontent.com/u/341801?v=3","gravatar_id":"","url":"https://api.github.com/users/nightwing","html_url":"https://github.com/nightwing","followers_url":"https://api.github.com/users/nightwing/followers","following_url":"https://api.github.com/users/nightwing/following{/other_user}","gists_url":"https://api.github.com/users/nightwing/gists{/gist_id}","starred_url":"https://api.github.com/users/nightwing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nightwing/subscriptions","organizations_url":"https://api.github.com/users/nightwing/orgs","repos_url":"https://api.github.com/users/nightwing/repos","events_url":"https://api.github.com/users/nightwing/events{/privacy}","received_events_url":"https://api.github.com/users/nightwing/received_events","type":"User","site_admin":false},"created_at":"2016-03-16T19:27:48Z","updated_at":"2016-03-16T19:27:48Z","body":"merged as https://github.com/c9/core/commit/0d240174b3238fa90eac1c52a1118c26cad25ce1"}}