{"action":"created","comment":{"url":"https://api.github.com/repos/resin-io/etcher/pulls/comments/188236270","pull_request_review_id":120169963,"id":188236270,"diff_hunk":"@@ -0,0 +1,164 @@\n+/*\n+ * Copyright 2018 resin.io\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *    http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+'use strict'\n+\n+const INDENTATION_SPACES = 2\n+\n+/**\n+ * @summary Localstorage class and helper functions\n+ * @class\n+ * @public\n+ */\n+class Storage {\n+  /**\n+   * @function\n+   * @public\n+   *\n+   * @param {String} superkey - superkey\n+   *\n+   * @example\n+   * const potatoStorage = new Storage('potato')\n+   */\n+  constructor (superkey) {\n+    this.superkey = superkey\n+  }\n+\n+  /**\n+   * @summary Get the whole object under the superkey\n+   * @function\n+   * @public\n+   *\n+   * @returns {Object}\n+   *\n+   * @example\n+   * for (const key in potatoStorage.getAll()) {\n+   *   console.log(key)\n+   * }\n+   */\n+  getAll () {\n+    try {\n+      // JSON.parse(null) === null, so we fallback to {}\n+      return JSON.parse(window.localStorage.getItem(this.superkey)) || {}\n+    } catch (err) {\n+      return {}","path":"lib/gui/app/models/storage.js","position":null,"original_position":57,"commit_id":"e76674a399ba3e82d70efaacc8da9c8cd0bad3bb","original_commit_id":"d8f086efe83e40a970569075f7a9a4977d32a68d","user":{"login":"Shou","id":819413,"avatar_url":"https://avatars1.githubusercontent.com/u/819413?v=4","gravatar_id":"","url":"https://api.github.com/users/Shou","html_url":"https://github.com/Shou","followers_url":"https://api.github.com/users/Shou/followers","following_url":"https://api.github.com/users/Shou/following{/other_user}","gists_url":"https://api.github.com/users/Shou/gists{/gist_id}","starred_url":"https://api.github.com/users/Shou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shou/subscriptions","organizations_url":"https://api.github.com/users/Shou/orgs","repos_url":"https://api.github.com/users/Shou/repos","events_url":"https://api.github.com/users/Shou/events{/privacy}","received_events_url":"https://api.github.com/users/Shou/received_events","type":"User","site_admin":false},"body":"How about this commit? We reset the value to an empty object and propagate the error subsequently so we don't allow the user to get stuck with a broken Etcher","created_at":"2018-05-15T10:19:36Z","updated_at":"2018-05-15T10:19:36Z","html_url":"https://github.com/resin-io/etcher/pull/2276#discussion_r188236270","pull_request_url":"https://api.github.com/repos/resin-io/etcher/pulls/2276","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/resin-io/etcher/pulls/comments/188236270"},"html":{"href":"https://github.com/resin-io/etcher/pull/2276#discussion_r188236270"},"pull_request":{"href":"https://api.github.com/repos/resin-io/etcher/pulls/2276"}},"in_reply_to_id":184775843},"pull_request":{"url":"https://api.github.com/repos/resin-io/etcher/pulls/2276","id":184092354,"html_url":"https://github.com/resin-io/etcher/pull/2276","diff_url":"https://github.com/resin-io/etcher/pull/2276.diff","patch_url":"https://github.com/resin-io/etcher/pull/2276.patch","issue_url":"https://api.github.com/repos/resin-io/etcher/issues/2276","number":2276,"state":"open","locked":false,"title":"feat(GUI): add convenience localstorage class","user":{"login":"Shou","id":819413,"avatar_url":"https://avatars1.githubusercontent.com/u/819413?v=4","gravatar_id":"","url":"https://api.github.com/users/Shou","html_url":"https://github.com/Shou","followers_url":"https://api.github.com/users/Shou/followers","following_url":"https://api.github.com/users/Shou/following{/other_user}","gists_url":"https://api.github.com/users/Shou/gists{/gist_id}","starred_url":"https://api.github.com/users/Shou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shou/subscriptions","organizations_url":"https://api.github.com/users/Shou/orgs","repos_url":"https://api.github.com/users/Shou/repos","events_url":"https://api.github.com/users/Shou/events{/privacy}","received_events_url":"https://api.github.com/users/Shou/received_events","type":"User","site_admin":false},"body":"We add a class `Storage` and accompanying helper methods that makes\r\nlocalStorage usage easier.\r\n\r\nChange-Type: patch\r\nChangelog-Entry: Add a convenience Storage class on top of localStorage.","created_at":"2018-04-25T16:25:36Z","updated_at":"2018-05-15T10:19:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2fb9e3867a915b660e75fe72f4855216155e3616","assignee":{"login":"Shou","id":819413,"avatar_url":"https://avatars1.githubusercontent.com/u/819413?v=4","gravatar_id":"","url":"https://api.github.com/users/Shou","html_url":"https://github.com/Shou","followers_url":"https://api.github.com/users/Shou/followers","following_url":"https://api.github.com/users/Shou/following{/other_user}","gists_url":"https://api.github.com/users/Shou/gists{/gist_id}","starred_url":"https://api.github.com/users/Shou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shou/subscriptions","organizations_url":"https://api.github.com/users/Shou/orgs","repos_url":"https://api.github.com/users/Shou/repos","events_url":"https://api.github.com/users/Shou/events{/privacy}","received_events_url":"https://api.github.com/users/Shou/received_events","type":"User","site_admin":false},"assignees":[{"login":"Shou","id":819413,"avatar_url":"https://avatars1.githubusercontent.com/u/819413?v=4","gravatar_id":"","url":"https://api.github.com/users/Shou","html_url":"https://github.com/Shou","followers_url":"https://api.github.com/users/Shou/followers","following_url":"https://api.github.com/users/Shou/following{/other_user}","gists_url":"https://api.github.com/users/Shou/gists{/gist_id}","starred_url":"https://api.github.com/users/Shou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shou/subscriptions","organizations_url":"https://api.github.com/users/Shou/orgs","repos_url":"https://api.github.com/users/Shou/repos","events_url":"https://api.github.com/users/Shou/events{/privacy}","received_events_url":"https://api.github.com/users/Shou/received_events","type":"User","site_admin":false}],"requested_reviewers":[{"login":"jviotti","id":2192773,"avatar_url":"https://avatars0.githubusercontent.com/u/2192773?v=4","gravatar_id":"","url":"https://api.github.com/users/jviotti","html_url":"https://github.com/jviotti","followers_url":"https://api.github.com/users/jviotti/followers","following_url":"https://api.github.com/users/jviotti/following{/other_user}","gists_url":"https://api.github.com/users/jviotti/gists{/gist_id}","starred_url":"https://api.github.com/users/jviotti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jviotti/subscriptions","organizations_url":"https://api.github.com/users/jviotti/orgs","repos_url":"https://api.github.com/users/jviotti/repos","events_url":"https://api.github.com/users/jviotti/events{/privacy}","received_events_url":"https://api.github.com/users/jviotti/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":310247012,"url":"https://api.github.com/repos/resin-io/etcher/labels/in%20progress","name":"in progress","color":"ededed","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/resin-io/etcher/pulls/2276/commits","review_comments_url":"https://api.github.com/repos/resin-io/etcher/pulls/2276/comments","review_comment_url":"https://api.github.com/repos/resin-io/etcher/pulls/comments{/number}","comments_url":"https://api.github.com/repos/resin-io/etcher/issues/2276/comments","statuses_url":"https://api.github.com/repos/resin-io/etcher/statuses/e76674a399ba3e82d70efaacc8da9c8cd0bad3bb","head":{"label":"resin-io:new-storage-class","ref":"new-storage-class","sha":"e76674a399ba3e82d70efaacc8da9c8cd0bad3bb","user":{"login":"resin-io","id":6157842,"avatar_url":"https://avatars1.githubusercontent.com/u/6157842?v=4","gravatar_id":"","url":"https://api.github.com/users/resin-io","html_url":"https://github.com/resin-io","followers_url":"https://api.github.com/users/resin-io/followers","following_url":"https://api.github.com/users/resin-io/following{/other_user}","gists_url":"https://api.github.com/users/resin-io/gists{/gist_id}","starred_url":"https://api.github.com/users/resin-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/resin-io/subscriptions","organizations_url":"https://api.github.com/users/resin-io/orgs","repos_url":"https://api.github.com/users/resin-io/repos","events_url":"https://api.github.com/users/resin-io/events{/privacy}","received_events_url":"https://api.github.com/users/resin-io/received_events","type":"Organization","site_admin":false},"repo":{"id":45055693,"name":"etcher","full_name":"resin-io/etcher","owner":{"login":"resin-io","id":6157842,"avatar_url":"https://avatars1.githubusercontent.com/u/6157842?v=4","gravatar_id":"","url":"https://api.github.com/users/resin-io","html_url":"https://github.com/resin-io","followers_url":"https://api.github.com/users/resin-io/followers","following_url":"https://api.github.com/users/resin-io/following{/other_user}","gists_url":"https://api.github.com/users/resin-io/gists{/gist_id}","starred_url":"https://api.github.com/users/resin-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/resin-io/subscriptions","organizations_url":"https://api.github.com/users/resin-io/orgs","repos_url":"https://api.github.com/users/resin-io/repos","events_url":"https://api.github.com/users/resin-io/events{/privacy}","received_events_url":"https://api.github.com/users/resin-io/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/resin-io/etcher","description":"Flash OS images to SD cards & USB drives, safely and easily.","fork":false,"url":"https://api.github.com/repos/resin-io/etcher","forks_url":"https://api.github.com/repos/resin-io/etcher/forks","keys_url":"https://api.github.com/repos/resin-io/etcher/keys{/key_id}","collaborators_url":"https://api.github.com/repos/resin-io/etcher/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/resin-io/etcher/teams","hooks_url":"https://api.github.com/repos/resin-io/etcher/hooks","issue_events_url":"https://api.github.com/repos/resin-io/etcher/issues/events{/number}","events_url":"https://api.github.com/repos/resin-io/etcher/events","assignees_url":"https://api.github.com/repos/resin-io/etcher/assignees{/user}","branches_url":"https://api.github.com/repos/resin-io/etcher/branches{/branch}","tags_url":"https://api.github.com/repos/resin-io/etcher/tags","blobs_url":"https://api.github.com/repos/resin-io/etcher/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/resin-io/etcher/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/resin-io/etcher/git/refs{/sha}","trees_url":"https://api.github.com/repos/resin-io/etcher/git/trees{/sha}","statuses_url":"https://api.github.com/repos/resin-io/etcher/statuses/{sha}","languages_url":"https://api.github.com/repos/resin-io/etcher/languages","stargazers_url":"https://api.github.com/repos/resin-io/etcher/stargazers","contributors_url":"https://api.github.com/repos/resin-io/etcher/contributors","subscribers_url":"https://api.github.com/repos/resin-io/etcher/subscribers","subscription_url":"https://api.github.com/repos/resin-io/etcher/subscription","commits_url":"https://api.github.com/repos/resin-io/etcher/commits{/sha}","git_commits_url":"https://api.github.com/repos/resin-io/etcher/git/commits{/sha}","comments_url":"https://api.github.com/repos/resin-io/etcher/comments{/number}","issue_comment_url":"https://api.github.com/repos/resin-io/etcher/issues/comments{/number}","contents_url":"https://api.github.com/repos/resin-io/etcher/contents/{+path}","compare_url":"https://api.github.com/repos/resin-io/etcher/compare/{base}...{head}","merges_url":"https://api.github.com/repos/resin-io/etcher/merges","archive_url":"https://api.github.com/repos/resin-io/etcher/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/resin-io/etcher/downloads","issues_url":"https://api.github.com/repos/resin-io/etcher/issues{/number}","pulls_url":"https://api.github.com/repos/resin-io/etcher/pulls{/number}","milestones_url":"https://api.github.com/repos/resin-io/etcher/milestones{/number}","notifications_url":"https://api.github.com/repos/resin-io/etcher/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/resin-io/etcher/labels{/name}","releases_url":"https://api.github.com/repos/resin-io/etcher/releases{/id}","deployments_url":"https://api.github.com/repos/resin-io/etcher/deployments","created_at":"2015-10-27T16:53:23Z","updated_at":"2018-05-15T09:32:44Z","pushed_at":"2018-05-15T10:11:09Z","git_url":"git://github.com/resin-io/etcher.git","ssh_url":"git@github.com:resin-io/etcher.git","clone_url":"https://github.com/resin-io/etcher.git","svn_url":"https://github.com/resin-io/etcher","homepage":"https://etcher.io","size":88098,"stargazers_count":10835,"watchers_count":10835,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":523,"mirror_url":null,"archived":false,"open_issues_count":247,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":523,"open_issues":247,"watchers":10835,"default_branch":"master"}},"base":{"label":"resin-io:master","ref":"master","sha":"81a75ca9555c76daf991f97f66eb0265dac32535","user":{"login":"resin-io","id":6157842,"avatar_url":"https://avatars1.githubusercontent.com/u/6157842?v=4","gravatar_id":"","url":"https://api.github.com/users/resin-io","html_url":"https://github.com/resin-io","followers_url":"https://api.github.com/users/resin-io/followers","following_url":"https://api.github.com/users/resin-io/following{/other_user}","gists_url":"https://api.github.com/users/resin-io/gists{/gist_id}","starred_url":"https://api.github.com/users/resin-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/resin-io/subscriptions","organizations_url":"https://api.github.com/users/resin-io/orgs","repos_url":"https://api.github.com/users/resin-io/repos","events_url":"https://api.github.com/users/resin-io/events{/privacy}","received_events_url":"https://api.github.com/users/resin-io/received_events","type":"Organization","site_admin":false},"repo":{"id":45055693,"name":"etcher","full_name":"resin-io/etcher","owner":{"login":"resin-io","id":6157842,"avatar_url":"https://avatars1.githubusercontent.com/u/6157842?v=4","gravatar_id":"","url":"https://api.github.com/users/resin-io","html_url":"https://github.com/resin-io","followers_url":"https://api.github.com/users/resin-io/followers","following_url":"https://api.github.com/users/resin-io/following{/other_user}","gists_url":"https://api.github.com/users/resin-io/gists{/gist_id}","starred_url":"https://api.github.com/users/resin-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/resin-io/subscriptions","organizations_url":"https://api.github.com/users/resin-io/orgs","repos_url":"https://api.github.com/users/resin-io/repos","events_url":"https://api.github.com/users/resin-io/events{/privacy}","received_events_url":"https://api.github.com/users/resin-io/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/resin-io/etcher","description":"Flash OS images to SD cards & USB drives, safely and easily.","fork":false,"url":"https://api.github.com/repos/resin-io/etcher","forks_url":"https://api.github.com/repos/resin-io/etcher/forks","keys_url":"https://api.github.com/repos/resin-io/etcher/keys{/key_id}","collaborators_url":"https://api.github.com/repos/resin-io/etcher/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/resin-io/etcher/teams","hooks_url":"https://api.github.com/repos/resin-io/etcher/hooks","issue_events_url":"https://api.github.com/repos/resin-io/etcher/issues/events{/number}","events_url":"https://api.github.com/repos/resin-io/etcher/events","assignees_url":"https://api.github.com/repos/resin-io/etcher/assignees{/user}","branches_url":"https://api.github.com/repos/resin-io/etcher/branches{/branch}","tags_url":"https://api.github.com/repos/resin-io/etcher/tags","blobs_url":"https://api.github.com/repos/resin-io/etcher/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/resin-io/etcher/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/resin-io/etcher/git/refs{/sha}","trees_url":"https://api.github.com/repos/resin-io/etcher/git/trees{/sha}","statuses_url":"https://api.github.com/repos/resin-io/etcher/statuses/{sha}","languages_url":"https://api.github.com/repos/resin-io/etcher/languages","stargazers_url":"https://api.github.com/repos/resin-io/etcher/stargazers","contributors_url":"https://api.github.com/repos/resin-io/etcher/contributors","subscribers_url":"https://api.github.com/repos/resin-io/etcher/subscribers","subscription_url":"https://api.github.com/repos/resin-io/etcher/subscription","commits_url":"https://api.github.com/repos/resin-io/etcher/commits{/sha}","git_commits_url":"https://api.github.com/repos/resin-io/etcher/git/commits{/sha}","comments_url":"https://api.github.com/repos/resin-io/etcher/comments{/number}","issue_comment_url":"https://api.github.com/repos/resin-io/etcher/issues/comments{/number}","contents_url":"https://api.github.com/repos/resin-io/etcher/contents/{+path}","compare_url":"https://api.github.com/repos/resin-io/etcher/compare/{base}...{head}","merges_url":"https://api.github.com/repos/resin-io/etcher/merges","archive_url":"https://api.github.com/repos/resin-io/etcher/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/resin-io/etcher/downloads","issues_url":"https://api.github.com/repos/resin-io/etcher/issues{/number}","pulls_url":"https://api.github.com/repos/resin-io/etcher/pulls{/number}","milestones_url":"https://api.github.com/repos/resin-io/etcher/milestones{/number}","notifications_url":"https://api.github.com/repos/resin-io/etcher/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/resin-io/etcher/labels{/name}","releases_url":"https://api.github.com/repos/resin-io/etcher/releases{/id}","deployments_url":"https://api.github.com/repos/resin-io/etcher/deployments","created_at":"2015-10-27T16:53:23Z","updated_at":"2018-05-15T09:32:44Z","pushed_at":"2018-05-15T10:11:09Z","git_url":"git://github.com/resin-io/etcher.git","ssh_url":"git@github.com:resin-io/etcher.git","clone_url":"https://github.com/resin-io/etcher.git","svn_url":"https://github.com/resin-io/etcher","homepage":"https://etcher.io","size":88098,"stargazers_count":10835,"watchers_count":10835,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":523,"mirror_url":null,"archived":false,"open_issues_count":247,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":523,"open_issues":247,"watchers":10835,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/resin-io/etcher/pulls/2276"},"html":{"href":"https://github.com/resin-io/etcher/pull/2276"},"issue":{"href":"https://api.github.com/repos/resin-io/etcher/issues/2276"},"comments":{"href":"https://api.github.com/repos/resin-io/etcher/issues/2276/comments"},"review_comments":{"href":"https://api.github.com/repos/resin-io/etcher/pulls/2276/comments"},"review_comment":{"href":"https://api.github.com/repos/resin-io/etcher/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/resin-io/etcher/pulls/2276/commits"},"statuses":{"href":"https://api.github.com/repos/resin-io/etcher/statuses/e76674a399ba3e82d70efaacc8da9c8cd0bad3bb"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"Shou"}}