{"action":"created","comment":{"url":"https://api.github.com/repos/poush/H2/pulls/comments/225034514","pull_request_review_id":164545430,"id":225034514,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNTAzNDUxNA==","diff_hunk":"@@ -0,0 +1,44 @@\n+/**\n+ * A simple storage utility to save the user config as json file\n+ * \n+ */\n+const electron = require('electron');\n+const path = require('path');\n+const fs = require('fs');\n+ class Store {\n+  constructor(opts = {}) {\n+    let defaultConfig = {\n+      configName: opts.configName || 'user',\n+      defaults: {\n+        alwaysWindowOnTop: true\n+      }\n+    }\n+     opts.defaults = Object.assign(defaultConfig.defaults, opts.defaultConfig);\n+     const userDataPath = (electron.app || electron.remote.app).getPath('userData');\n+    // Use the `configName` property to set the file name and path.join to bring it all together as a string\n+    this.path = path.join(userDataPath, opts.configName + '.json');\n+    \n+    this.data = parseDataFile(this.path, opts.defaults);\n+  }\n+  \n+  get(key) {\n+    return this.data[key];\n+  }\n+  \n+  set(key, val) {\n+    this.data[key] = val;\n+    try{\n+      fs.writeFileSync(this.path, JSON.stringify(this.data));\n+    }catch(err) {\n+      console.error('Failed to save user config');\n+    }\n+  }\n+}\n+ function parseDataFile(filePath, defaults) {\n+  try {\n+    return JSON.parse(fs.readFileSync(filePath));\n+  } catch(error) {\n+    return defaults;\n+  }\n+}\n+ module.exports = Store;","path":"storage/storage.js","position":44,"original_position":44,"commit_id":"699dbea26931a47474108e32eccced14198c1352","original_commit_id":"699dbea26931a47474108e32eccced14198c1352","user":{"login":"saravanan10393","id":10221219,"node_id":"MDQ6VXNlcjEwMjIxMjE5","avatar_url":"https://avatars3.githubusercontent.com/u/10221219?v=4","gravatar_id":"","url":"https://api.github.com/users/saravanan10393","html_url":"https://github.com/saravanan10393","followers_url":"https://api.github.com/users/saravanan10393/followers","following_url":"https://api.github.com/users/saravanan10393/following{/other_user}","gists_url":"https://api.github.com/users/saravanan10393/gists{/gist_id}","starred_url":"https://api.github.com/users/saravanan10393/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saravanan10393/subscriptions","organizations_url":"https://api.github.com/users/saravanan10393/orgs","repos_url":"https://api.github.com/users/saravanan10393/repos","events_url":"https://api.github.com/users/saravanan10393/events{/privacy}","received_events_url":"https://api.github.com/users/saravanan10393/received_events","type":"User","site_admin":false},"body":"If we do so we can create only one config file, what if i want to create another configuration for something else. I do one thing, i export store as well as default config instance\r\n`\r\n export.default = new Storage({})\r\n export.Storage = Storage\r\n`\r\n\r\nIs that ok for you.","created_at":"2018-10-15T04:16:41Z","updated_at":"2018-10-15T04:16:42Z","html_url":"https://github.com/poush/H2/pull/54#discussion_r225034514","pull_request_url":"https://api.github.com/repos/poush/H2/pulls/54","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/poush/H2/pulls/comments/225034514"},"html":{"href":"https://github.com/poush/H2/pull/54#discussion_r225034514"},"pull_request":{"href":"https://api.github.com/repos/poush/H2/pulls/54"}},"in_reply_to_id":224989108},"pull_request":{"url":"https://api.github.com/repos/poush/H2/pulls/54","id":222708961,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIyNzA4OTYx","html_url":"https://github.com/poush/H2/pull/54","diff_url":"https://github.com/poush/H2/pull/54.diff","patch_url":"https://github.com/poush/H2/pull/54.patch","issue_url":"https://api.github.com/repos/poush/H2/issues/54","number":54,"state":"open","locked":false,"title":"Interface to save user configuration in a file","user":{"login":"saravanan10393","id":10221219,"node_id":"MDQ6VXNlcjEwMjIxMjE5","avatar_url":"https://avatars3.githubusercontent.com/u/10221219?v=4","gravatar_id":"","url":"https://api.github.com/users/saravanan10393","html_url":"https://github.com/saravanan10393","followers_url":"https://api.github.com/users/saravanan10393/followers","following_url":"https://api.github.com/users/saravanan10393/following{/other_user}","gists_url":"https://api.github.com/users/saravanan10393/gists{/gist_id}","starred_url":"https://api.github.com/users/saravanan10393/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saravanan10393/subscriptions","organizations_url":"https://api.github.com/users/saravanan10393/orgs","repos_url":"https://api.github.com/users/saravanan10393/repos","events_url":"https://api.github.com/users/saravanan10393/events{/privacy}","received_events_url":"https://api.github.com/users/saravanan10393/received_events","type":"User","site_admin":false},"body":"#### Tracking Issue: #53 \r\n","created_at":"2018-10-14T11:16:36Z","updated_at":"2018-10-15T04:16:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a640ccdfe9971b1eb1eff624a3273d2c9867c1ed","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/poush/H2/pulls/54/commits","review_comments_url":"https://api.github.com/repos/poush/H2/pulls/54/comments","review_comment_url":"https://api.github.com/repos/poush/H2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/poush/H2/issues/54/comments","statuses_url":"https://api.github.com/repos/poush/H2/statuses/699dbea26931a47474108e32eccced14198c1352","head":{"label":"saravanan10393:store","ref":"store","sha":"699dbea26931a47474108e32eccced14198c1352","user":{"login":"saravanan10393","id":10221219,"node_id":"MDQ6VXNlcjEwMjIxMjE5","avatar_url":"https://avatars3.githubusercontent.com/u/10221219?v=4","gravatar_id":"","url":"https://api.github.com/users/saravanan10393","html_url":"https://github.com/saravanan10393","followers_url":"https://api.github.com/users/saravanan10393/followers","following_url":"https://api.github.com/users/saravanan10393/following{/other_user}","gists_url":"https://api.github.com/users/saravanan10393/gists{/gist_id}","starred_url":"https://api.github.com/users/saravanan10393/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saravanan10393/subscriptions","organizations_url":"https://api.github.com/users/saravanan10393/orgs","repos_url":"https://api.github.com/users/saravanan10393/repos","events_url":"https://api.github.com/users/saravanan10393/events{/privacy}","received_events_url":"https://api.github.com/users/saravanan10393/received_events","type":"User","site_admin":false},"repo":{"id":152858955,"node_id":"MDEwOlJlcG9zaXRvcnkxNTI4NTg5NTU=","name":"H2","full_name":"saravanan10393/H2","private":false,"owner":{"login":"saravanan10393","id":10221219,"node_id":"MDQ6VXNlcjEwMjIxMjE5","avatar_url":"https://avatars3.githubusercontent.com/u/10221219?v=4","gravatar_id":"","url":"https://api.github.com/users/saravanan10393","html_url":"https://github.com/saravanan10393","followers_url":"https://api.github.com/users/saravanan10393/followers","following_url":"https://api.github.com/users/saravanan10393/following{/other_user}","gists_url":"https://api.github.com/users/saravanan10393/gists{/gist_id}","starred_url":"https://api.github.com/users/saravanan10393/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saravanan10393/subscriptions","organizations_url":"https://api.github.com/users/saravanan10393/orgs","repos_url":"https://api.github.com/users/saravanan10393/repos","events_url":"https://api.github.com/users/saravanan10393/events{/privacy}","received_events_url":"https://api.github.com/users/saravanan10393/received_events","type":"User","site_admin":false},"html_url":"https://github.com/saravanan10393/H2","description":"🖥A minimalist browser to watch embed anything on picture-on-picture mode. ","fork":true,"url":"https://api.github.com/repos/saravanan10393/H2","forks_url":"https://api.github.com/repos/saravanan10393/H2/forks","keys_url":"https://api.github.com/repos/saravanan10393/H2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/saravanan10393/H2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/saravanan10393/H2/teams","hooks_url":"https://api.github.com/repos/saravanan10393/H2/hooks","issue_events_url":"https://api.github.com/repos/saravanan10393/H2/issues/events{/number}","events_url":"https://api.github.com/repos/saravanan10393/H2/events","assignees_url":"https://api.github.com/repos/saravanan10393/H2/assignees{/user}","branches_url":"https://api.github.com/repos/saravanan10393/H2/branches{/branch}","tags_url":"https://api.github.com/repos/saravanan10393/H2/tags","blobs_url":"https://api.github.com/repos/saravanan10393/H2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/saravanan10393/H2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/saravanan10393/H2/git/refs{/sha}","trees_url":"https://api.github.com/repos/saravanan10393/H2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/saravanan10393/H2/statuses/{sha}","languages_url":"https://api.github.com/repos/saravanan10393/H2/languages","stargazers_url":"https://api.github.com/repos/saravanan10393/H2/stargazers","contributors_url":"https://api.github.com/repos/saravanan10393/H2/contributors","subscribers_url":"https://api.github.com/repos/saravanan10393/H2/subscribers","subscription_url":"https://api.github.com/repos/saravanan10393/H2/subscription","commits_url":"https://api.github.com/repos/saravanan10393/H2/commits{/sha}","git_commits_url":"https://api.github.com/repos/saravanan10393/H2/git/commits{/sha}","comments_url":"https://api.github.com/repos/saravanan10393/H2/comments{/number}","issue_comment_url":"https://api.github.com/repos/saravanan10393/H2/issues/comments{/number}","contents_url":"https://api.github.com/repos/saravanan10393/H2/contents/{+path}","compare_url":"https://api.github.com/repos/saravanan10393/H2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/saravanan10393/H2/merges","archive_url":"https://api.github.com/repos/saravanan10393/H2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/saravanan10393/H2/downloads","issues_url":"https://api.github.com/repos/saravanan10393/H2/issues{/number}","pulls_url":"https://api.github.com/repos/saravanan10393/H2/pulls{/number}","milestones_url":"https://api.github.com/repos/saravanan10393/H2/milestones{/number}","notifications_url":"https://api.github.com/repos/saravanan10393/H2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/saravanan10393/H2/labels{/name}","releases_url":"https://api.github.com/repos/saravanan10393/H2/releases{/id}","deployments_url":"https://api.github.com/repos/saravanan10393/H2/deployments","created_at":"2018-10-13T10:03:31Z","updated_at":"2018-10-14T17:40:33Z","pushed_at":"2018-10-14T17:40:31Z","git_url":"git://github.com/saravanan10393/H2.git","ssh_url":"git@github.com:saravanan10393/H2.git","clone_url":"https://github.com/saravanan10393/H2.git","svn_url":"https://github.com/saravanan10393/H2","homepage":"","size":47599,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"cc0-1.0","name":"Creative Commons Zero v1.0 Universal","spdx_id":"CC0-1.0","url":"https://api.github.com/licenses/cc0-1.0","node_id":"MDc6TGljZW5zZTY="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"poush:master","ref":"master","sha":"2f98f781e80b8ed4a5cd977e288da818e7e1ce0a","user":{"login":"poush","id":1812082,"node_id":"MDQ6VXNlcjE4MTIwODI=","avatar_url":"https://avatars0.githubusercontent.com/u/1812082?v=4","gravatar_id":"","url":"https://api.github.com/users/poush","html_url":"https://github.com/poush","followers_url":"https://api.github.com/users/poush/followers","following_url":"https://api.github.com/users/poush/following{/other_user}","gists_url":"https://api.github.com/users/poush/gists{/gist_id}","starred_url":"https://api.github.com/users/poush/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/poush/subscriptions","organizations_url":"https://api.github.com/users/poush/orgs","repos_url":"https://api.github.com/users/poush/repos","events_url":"https://api.github.com/users/poush/events{/privacy}","received_events_url":"https://api.github.com/users/poush/received_events","type":"User","site_admin":false},"repo":{"id":146895974,"node_id":"MDEwOlJlcG9zaXRvcnkxNDY4OTU5NzQ=","name":"H2","full_name":"poush/H2","private":false,"owner":{"login":"poush","id":1812082,"node_id":"MDQ6VXNlcjE4MTIwODI=","avatar_url":"https://avatars0.githubusercontent.com/u/1812082?v=4","gravatar_id":"","url":"https://api.github.com/users/poush","html_url":"https://github.com/poush","followers_url":"https://api.github.com/users/poush/followers","following_url":"https://api.github.com/users/poush/following{/other_user}","gists_url":"https://api.github.com/users/poush/gists{/gist_id}","starred_url":"https://api.github.com/users/poush/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/poush/subscriptions","organizations_url":"https://api.github.com/users/poush/orgs","repos_url":"https://api.github.com/users/poush/repos","events_url":"https://api.github.com/users/poush/events{/privacy}","received_events_url":"https://api.github.com/users/poush/received_events","type":"User","site_admin":false},"html_url":"https://github.com/poush/H2","description":"🖥A minimalist browser to watch embed anything on picture-in-picture mode. ","fork":false,"url":"https://api.github.com/repos/poush/H2","forks_url":"https://api.github.com/repos/poush/H2/forks","keys_url":"https://api.github.com/repos/poush/H2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/poush/H2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/poush/H2/teams","hooks_url":"https://api.github.com/repos/poush/H2/hooks","issue_events_url":"https://api.github.com/repos/poush/H2/issues/events{/number}","events_url":"https://api.github.com/repos/poush/H2/events","assignees_url":"https://api.github.com/repos/poush/H2/assignees{/user}","branches_url":"https://api.github.com/repos/poush/H2/branches{/branch}","tags_url":"https://api.github.com/repos/poush/H2/tags","blobs_url":"https://api.github.com/repos/poush/H2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/poush/H2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/poush/H2/git/refs{/sha}","trees_url":"https://api.github.com/repos/poush/H2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/poush/H2/statuses/{sha}","languages_url":"https://api.github.com/repos/poush/H2/languages","stargazers_url":"https://api.github.com/repos/poush/H2/stargazers","contributors_url":"https://api.github.com/repos/poush/H2/contributors","subscribers_url":"https://api.github.com/repos/poush/H2/subscribers","subscription_url":"https://api.github.com/repos/poush/H2/subscription","commits_url":"https://api.github.com/repos/poush/H2/commits{/sha}","git_commits_url":"https://api.github.com/repos/poush/H2/git/commits{/sha}","comments_url":"https://api.github.com/repos/poush/H2/comments{/number}","issue_comment_url":"https://api.github.com/repos/poush/H2/issues/comments{/number}","contents_url":"https://api.github.com/repos/poush/H2/contents/{+path}","compare_url":"https://api.github.com/repos/poush/H2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/poush/H2/merges","archive_url":"https://api.github.com/repos/poush/H2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/poush/H2/downloads","issues_url":"https://api.github.com/repos/poush/H2/issues{/number}","pulls_url":"https://api.github.com/repos/poush/H2/pulls{/number}","milestones_url":"https://api.github.com/repos/poush/H2/milestones{/number}","notifications_url":"https://api.github.com/repos/poush/H2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/poush/H2/labels{/name}","releases_url":"https://api.github.com/repos/poush/H2/releases{/id}","deployments_url":"https://api.github.com/repos/poush/H2/deployments","created_at":"2018-08-31T13:30:42Z","updated_at":"2018-10-14T19:59:03Z","pushed_at":"2018-10-14T19:40:35Z","git_url":"git://github.com/poush/H2.git","ssh_url":"git@github.com:poush/H2.git","clone_url":"https://github.com/poush/H2.git","svn_url":"https://github.com/poush/H2","homepage":"","size":47593,"stargazers_count":6,"watchers_count":6,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":23,"mirror_url":null,"archived":false,"open_issues_count":21,"license":{"key":"cc0-1.0","name":"Creative Commons Zero v1.0 Universal","spdx_id":"CC0-1.0","url":"https://api.github.com/licenses/cc0-1.0","node_id":"MDc6TGljZW5zZTY="},"forks":23,"open_issues":21,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/poush/H2/pulls/54"},"html":{"href":"https://github.com/poush/H2/pull/54"},"issue":{"href":"https://api.github.com/repos/poush/H2/issues/54"},"comments":{"href":"https://api.github.com/repos/poush/H2/issues/54/comments"},"review_comments":{"href":"https://api.github.com/repos/poush/H2/pulls/54/comments"},"review_comment":{"href":"https://api.github.com/repos/poush/H2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/poush/H2/pulls/54/commits"},"statuses":{"href":"https://api.github.com/repos/poush/H2/statuses/699dbea26931a47474108e32eccced14198c1352"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"saravanan10393"}}