{"action":"created","comment":{"url":"https://api.github.com/repos/amb26/linux/pulls/comments/59561361","id":59561361,"diff_hunk":"@@ -53,129 +41,98 @@\n     fluid.registerNamespace(\"gpii.launch\");\n     fluid.registerNamespace(\"gpii.orca\");\n \n-    // TODO: Remove this method and all the blocking stuff.\n-    // (see https://github.com/GPII/linux/pull/16)\n-    //\n-    // This setting handler has to be converted to an asynchronous as soon as\n-    // the lifecycle manager can handle asynchronous actions.\n-    //\n-    // The reason for this blocking code is because we need a mechanism to know\n-    // when the Orca's settings file has been created.\n-    //\n-    // The blocking \"while loop\" is where this method is used and is a big\n-    // stability risk to the system, since it blocks the node event loop\n-    // possibly indefinitely.\n-    //\n-    // Once we can make this setting handler to be asynchronous, we can use\n-    // fs.watch or any other similar asynchronous approaches to know\n-    // when the orca settings file is being created.\n-    //\n-    function wait(millis) {\n-        var date = new Date();\n-        var curDate;\n-\n-        do { curDate = new Date(); }\n-        while (curDate - date < millis);\n-    }\n-\n-    function applySettings(app) {\n-        var settings = app.settings;\n-\n-        var userSettings = require(orcaSettingsFile);\n-        var currentSettingsInProfile = userSettings.profiles[userSettings.general.activeProfile[PROFILE_ID]];\n-\n-        var applier = fluid.makeChangeApplier(currentSettingsInProfile, {\n+    fluid.defaults(\"gpii.orca.settingsHandler\", {\n+        gradeNames: [\"fluid.modelComponent\"],\n+        changeApplierOptions: {\n             resolverGetConfig: fluid.model.escapedGetConfig,\n             resolverSetConfig: fluid.model.escapedSetConfig\n-        });\n-\n-        var newSettingsResponse = {};\n-        fluid.each(settings, function (settingVal, settingKey) {\n-            var oldValue = fluid.get(currentSettingsInProfile, settingKey,\n-                fluid.model.escapedGetConfig);\n+        },\n+        model: {\n+            settings: {}\n+        },\n+        invokers: {\n+            get: {\n+                funcName: \"gpii.orca.settingsHandler.get\",\n+                args: [\"{that}\", \"{arguments}.0\"]\n+            },\n+            set: {\n+                funcName: \"gpii.orca.settingsHandler.set\",\n+                args: [\"{that}\", \"{arguments}.0\"]\n+            },\n+            getImpl: {\n+                funcName: \"gpii.orca.settingsHandler.getImpl\",\n+                args: [\"{that}\", \"{arguments}.0\"]\n+            },\n+            setImpl: {\n+                funcName: \"gpii.orca.settingsHandler.setImpl\",\n+                args: [\"{that}\", \"{arguments}.0\"]\n+            }\n+        },\n+        listeners: {\n+            onCreate: {\n+                funcName: \"gpii.orca.settingsHandler.onCreate\",\n+                args: [\"{that}\"]\n+            }\n+        }\n+    });\n \n-            var change = {\n-                path: settingKey,\n-                value: settingVal\n-            };\n-            change.type = settingVal === undefined ? \"DELETE\" : \"ADD\";\n-            applier.fireChangeRequest(change);\n+    gpii.orca.settingsHandler.onCreate = function (that) {\n+        var userSettings = fs.readFileSync(orcaSettingsFile);\n+        that.applier.change(\"settings\", JSON.parse(userSettings));\n+    };\n \n-            newSettingsResponse[settingKey] = {\n-                \"oldValue\": oldValue,\n-                \"newValue\": settingVal\n-            };\n+    gpii.orca.settingsHandler.getImpl = function (that, payload) {\n+        var profile = that.model.settings.general.activeProfile[PROFILE_ID];\n \n-            fluid.set(currentSettingsInProfile, settingKey, settings[settingKey],\n-                      fluid.model.escapedSetConfig);\n+        var results = fluid.transform(payload.settings, function (value, key) {\n+            var currentValue = fluid.get(that.model.settings, [\"profiles\", profile, key]);\n+            return currentValue;\n         });\n \n-        userSettings.profiles[userSettings.general.activeProfile[PROFILE_ID]] = currentSettingsInProfile;\n+        return results;\n+    };\n \n-        fs.writeFileSync(orcaSettingsFile,\n-                         JSON.stringify(userSettings, null, 4));\n+    gpii.orca.settingsHandler.setImpl = function (that, payload) {\n+        var profile = that.model.settings.general.activeProfile[PROFILE_ID];\n \n-        return newSettingsResponse;\n-    }\n+        var results = fluid.transform(payload.settings, function (value, key) {\n+            var oldValue = fluid.get(that.model.settings, [\"profiles\", profile, key]);\n+            var type;\n \n-    gpii.orca.getImpl = function (payload) {\n-        var app = fluid.copy(payload);\n+            if (oldValue === undefined) {\n+                type = \"ADD\";\n+            } else if (value === undefined) {\n+                type = \"DELETE\";\n+            } else {\n+                type = null;","path":"gpii/node_modules/orca/orcaSettingsHandler.js","position":157,"original_position":157,"commit_id":"a9ee8266145807d74eed5116ba1c47429362af6d","original_commit_id":"a9ee8266145807d74eed5116ba1c47429362af6d","user":{"login":"amb26","id":561418,"avatar_url":"https://avatars.githubusercontent.com/u/561418?v=3","gravatar_id":"","url":"https://api.github.com/users/amb26","html_url":"https://github.com/amb26","followers_url":"https://api.github.com/users/amb26/followers","following_url":"https://api.github.com/users/amb26/following{/other_user}","gists_url":"https://api.github.com/users/amb26/gists{/gist_id}","starred_url":"https://api.github.com/users/amb26/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amb26/subscriptions","organizations_url":"https://api.github.com/users/amb26/orgs","repos_url":"https://api.github.com/users/amb26/repos","events_url":"https://api.github.com/users/amb26/events{/privacy}","received_events_url":"https://api.github.com/users/amb26/received_events","type":"User","site_admin":false},"body":"This is still an \"ADD\"","created_at":"2016-04-13T14:45:58Z","updated_at":"2016-04-13T14:45:58Z","html_url":"https://github.com/amb26/linux/pull/2#discussion_r59561361","pull_request_url":"https://api.github.com/repos/amb26/linux/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/amb26/linux/pulls/comments/59561361"},"html":{"href":"https://github.com/amb26/linux/pull/2#discussion_r59561361"},"pull_request":{"href":"https://api.github.com/repos/amb26/linux/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/amb26/linux/pulls/2","id":52924251,"html_url":"https://github.com/amb26/linux/pull/2","diff_url":"https://github.com/amb26/linux/pull/2.diff","patch_url":"https://github.com/amb26/linux/pull/2.patch","issue_url":"https://api.github.com/repos/amb26/linux/issues/2","number":2,"state":"open","locked":false,"title":"GPII-1526: Port native addons to nan","user":{"login":"javihernandez","id":821790,"avatar_url":"https://avatars.githubusercontent.com/u/821790?v=3","gravatar_id":"","url":"https://api.github.com/users/javihernandez","html_url":"https://github.com/javihernandez","followers_url":"https://api.github.com/users/javihernandez/followers","following_url":"https://api.github.com/users/javihernandez/following{/other_user}","gists_url":"https://api.github.com/users/javihernandez/gists{/gist_id}","starred_url":"https://api.github.com/users/javihernandez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javihernandez/subscriptions","organizations_url":"https://api.github.com/users/javihernandez/orgs","repos_url":"https://api.github.com/users/javihernandez/repos","events_url":"https://api.github.com/users/javihernandez/events{/privacy}","received_events_url":"https://api.github.com/users/javihernandez/received_events","type":"User","site_admin":false},"body":"Hey @amb26, \r\n\r\nI've ported our native modules to nan, so this is ready for you to start reviewing it.\r\nThe only missing piece is the packageKit addon, which is being ported by @klown and will end up in this branch for you to review too.","created_at":"2015-12-08T00:56:09Z","updated_at":"2016-04-13T14:45:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2a7e317dc7e5cf0fa624332d48901b6b35e5c363","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/amb26/linux/pulls/2/commits","review_comments_url":"https://api.github.com/repos/amb26/linux/pulls/2/comments","review_comment_url":"https://api.github.com/repos/amb26/linux/pulls/comments{/number}","comments_url":"https://api.github.com/repos/amb26/linux/issues/2/comments","statuses_url":"https://api.github.com/repos/amb26/linux/statuses/a9ee8266145807d74eed5116ba1c47429362af6d","head":{"label":"javihernandez:GPII-1526","ref":"GPII-1526","sha":"a9ee8266145807d74eed5116ba1c47429362af6d","user":{"login":"javihernandez","id":821790,"avatar_url":"https://avatars.githubusercontent.com/u/821790?v=3","gravatar_id":"","url":"https://api.github.com/users/javihernandez","html_url":"https://github.com/javihernandez","followers_url":"https://api.github.com/users/javihernandez/followers","following_url":"https://api.github.com/users/javihernandez/following{/other_user}","gists_url":"https://api.github.com/users/javihernandez/gists{/gist_id}","starred_url":"https://api.github.com/users/javihernandez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javihernandez/subscriptions","organizations_url":"https://api.github.com/users/javihernandez/orgs","repos_url":"https://api.github.com/users/javihernandez/repos","events_url":"https://api.github.com/users/javihernandez/events{/privacy}","received_events_url":"https://api.github.com/users/javihernandez/received_events","type":"User","site_admin":false},"repo":{"id":4283441,"name":"linux","full_name":"javihernandez/linux","owner":{"login":"javihernandez","id":821790,"avatar_url":"https://avatars.githubusercontent.com/u/821790?v=3","gravatar_id":"","url":"https://api.github.com/users/javihernandez","html_url":"https://github.com/javihernandez","followers_url":"https://api.github.com/users/javihernandez/followers","following_url":"https://api.github.com/users/javihernandez/following{/other_user}","gists_url":"https://api.github.com/users/javihernandez/gists{/gist_id}","starred_url":"https://api.github.com/users/javihernandez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javihernandez/subscriptions","organizations_url":"https://api.github.com/users/javihernandez/orgs","repos_url":"https://api.github.com/users/javihernandez/repos","events_url":"https://api.github.com/users/javihernandez/events{/privacy}","received_events_url":"https://api.github.com/users/javihernandez/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/javihernandez/linux","description":"","fork":true,"url":"https://api.github.com/repos/javihernandez/linux","forks_url":"https://api.github.com/repos/javihernandez/linux/forks","keys_url":"https://api.github.com/repos/javihernandez/linux/keys{/key_id}","collaborators_url":"https://api.github.com/repos/javihernandez/linux/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/javihernandez/linux/teams","hooks_url":"https://api.github.com/repos/javihernandez/linux/hooks","issue_events_url":"https://api.github.com/repos/javihernandez/linux/issues/events{/number}","events_url":"https://api.github.com/repos/javihernandez/linux/events","assignees_url":"https://api.github.com/repos/javihernandez/linux/assignees{/user}","branches_url":"https://api.github.com/repos/javihernandez/linux/branches{/branch}","tags_url":"https://api.github.com/repos/javihernandez/linux/tags","blobs_url":"https://api.github.com/repos/javihernandez/linux/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/javihernandez/linux/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/javihernandez/linux/git/refs{/sha}","trees_url":"https://api.github.com/repos/javihernandez/linux/git/trees{/sha}","statuses_url":"https://api.github.com/repos/javihernandez/linux/statuses/{sha}","languages_url":"https://api.github.com/repos/javihernandez/linux/languages","stargazers_url":"https://api.github.com/repos/javihernandez/linux/stargazers","contributors_url":"https://api.github.com/repos/javihernandez/linux/contributors","subscribers_url":"https://api.github.com/repos/javihernandez/linux/subscribers","subscription_url":"https://api.github.com/repos/javihernandez/linux/subscription","commits_url":"https://api.github.com/repos/javihernandez/linux/commits{/sha}","git_commits_url":"https://api.github.com/repos/javihernandez/linux/git/commits{/sha}","comments_url":"https://api.github.com/repos/javihernandez/linux/comments{/number}","issue_comment_url":"https://api.github.com/repos/javihernandez/linux/issues/comments{/number}","contents_url":"https://api.github.com/repos/javihernandez/linux/contents/{+path}","compare_url":"https://api.github.com/repos/javihernandez/linux/compare/{base}...{head}","merges_url":"https://api.github.com/repos/javihernandez/linux/merges","archive_url":"https://api.github.com/repos/javihernandez/linux/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/javihernandez/linux/downloads","issues_url":"https://api.github.com/repos/javihernandez/linux/issues{/number}","pulls_url":"https://api.github.com/repos/javihernandez/linux/pulls{/number}","milestones_url":"https://api.github.com/repos/javihernandez/linux/milestones{/number}","notifications_url":"https://api.github.com/repos/javihernandez/linux/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/javihernandez/linux/labels{/name}","releases_url":"https://api.github.com/repos/javihernandez/linux/releases{/id}","deployments_url":"https://api.github.com/repos/javihernandez/linux/deployments","created_at":"2012-05-10T11:06:03Z","updated_at":"2015-02-09T10:45:06Z","pushed_at":"2015-12-17T15:11:46Z","git_url":"git://github.com/javihernandez/linux.git","ssh_url":"git@github.com:javihernandez/linux.git","clone_url":"https://github.com/javihernandez/linux.git","svn_url":"https://github.com/javihernandez/linux","homepage":"","size":666,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":3,"default_branch":"master"}},"base":{"label":"amb26:GPII-1318","ref":"GPII-1318","sha":"3e6b6b662ef9e550d6a3fb11d787e9f9ce1f9b0a","user":{"login":"amb26","id":561418,"avatar_url":"https://avatars.githubusercontent.com/u/561418?v=3","gravatar_id":"","url":"https://api.github.com/users/amb26","html_url":"https://github.com/amb26","followers_url":"https://api.github.com/users/amb26/followers","following_url":"https://api.github.com/users/amb26/following{/other_user}","gists_url":"https://api.github.com/users/amb26/gists{/gist_id}","starred_url":"https://api.github.com/users/amb26/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amb26/subscriptions","organizations_url":"https://api.github.com/users/amb26/orgs","repos_url":"https://api.github.com/users/amb26/repos","events_url":"https://api.github.com/users/amb26/events{/privacy}","received_events_url":"https://api.github.com/users/amb26/received_events","type":"User","site_admin":false},"repo":{"id":22614513,"name":"linux","full_name":"amb26/linux","owner":{"login":"amb26","id":561418,"avatar_url":"https://avatars.githubusercontent.com/u/561418?v=3","gravatar_id":"","url":"https://api.github.com/users/amb26","html_url":"https://github.com/amb26","followers_url":"https://api.github.com/users/amb26/followers","following_url":"https://api.github.com/users/amb26/following{/other_user}","gists_url":"https://api.github.com/users/amb26/gists{/gist_id}","starred_url":"https://api.github.com/users/amb26/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amb26/subscriptions","organizations_url":"https://api.github.com/users/amb26/orgs","repos_url":"https://api.github.com/users/amb26/repos","events_url":"https://api.github.com/users/amb26/events{/privacy}","received_events_url":"https://api.github.com/users/amb26/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/amb26/linux","description":"","fork":true,"url":"https://api.github.com/repos/amb26/linux","forks_url":"https://api.github.com/repos/amb26/linux/forks","keys_url":"https://api.github.com/repos/amb26/linux/keys{/key_id}","collaborators_url":"https://api.github.com/repos/amb26/linux/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/amb26/linux/teams","hooks_url":"https://api.github.com/repos/amb26/linux/hooks","issue_events_url":"https://api.github.com/repos/amb26/linux/issues/events{/number}","events_url":"https://api.github.com/repos/amb26/linux/events","assignees_url":"https://api.github.com/repos/amb26/linux/assignees{/user}","branches_url":"https://api.github.com/repos/amb26/linux/branches{/branch}","tags_url":"https://api.github.com/repos/amb26/linux/tags","blobs_url":"https://api.github.com/repos/amb26/linux/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/amb26/linux/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/amb26/linux/git/refs{/sha}","trees_url":"https://api.github.com/repos/amb26/linux/git/trees{/sha}","statuses_url":"https://api.github.com/repos/amb26/linux/statuses/{sha}","languages_url":"https://api.github.com/repos/amb26/linux/languages","stargazers_url":"https://api.github.com/repos/amb26/linux/stargazers","contributors_url":"https://api.github.com/repos/amb26/linux/contributors","subscribers_url":"https://api.github.com/repos/amb26/linux/subscribers","subscription_url":"https://api.github.com/repos/amb26/linux/subscription","commits_url":"https://api.github.com/repos/amb26/linux/commits{/sha}","git_commits_url":"https://api.github.com/repos/amb26/linux/git/commits{/sha}","comments_url":"https://api.github.com/repos/amb26/linux/comments{/number}","issue_comment_url":"https://api.github.com/repos/amb26/linux/issues/comments{/number}","contents_url":"https://api.github.com/repos/amb26/linux/contents/{+path}","compare_url":"https://api.github.com/repos/amb26/linux/compare/{base}...{head}","merges_url":"https://api.github.com/repos/amb26/linux/merges","archive_url":"https://api.github.com/repos/amb26/linux/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/amb26/linux/downloads","issues_url":"https://api.github.com/repos/amb26/linux/issues{/number}","pulls_url":"https://api.github.com/repos/amb26/linux/pulls{/number}","milestones_url":"https://api.github.com/repos/amb26/linux/milestones{/number}","notifications_url":"https://api.github.com/repos/amb26/linux/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/amb26/linux/labels{/name}","releases_url":"https://api.github.com/repos/amb26/linux/releases{/id}","deployments_url":"https://api.github.com/repos/amb26/linux/deployments","created_at":"2014-08-04T18:09:21Z","updated_at":"2014-07-11T20:07:51Z","pushed_at":"2015-12-15T13:13:35Z","git_url":"git://github.com/amb26/linux.git","ssh_url":"git@github.com:amb26/linux.git","clone_url":"https://github.com/amb26/linux.git","svn_url":"https://github.com/amb26/linux","homepage":"","size":569,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/amb26/linux/pulls/2"},"html":{"href":"https://github.com/amb26/linux/pull/2"},"issue":{"href":"https://api.github.com/repos/amb26/linux/issues/2"},"comments":{"href":"https://api.github.com/repos/amb26/linux/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/amb26/linux/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/amb26/linux/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/amb26/linux/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/amb26/linux/statuses/a9ee8266145807d74eed5116ba1c47429362af6d"}}}}