{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments/29323132","id":29323132,"diff_hunk":"@@ -1,112 +1,301 @@\n-/* global CardManager, MozActivity */\n+/* global evt, Promise, asyncStorage */\n \n 'use strict';\n \n (function(exports) {\n \n-  /**\n-   * ChannelManager implements pin/unpin card to/from home funcitons and\n-   * update pin button information in both button-group-panel and contextmenu.\n-   */\n-  function ChannelManager(tvDeck) {\n+  function ChannelManager() {\n \n-    this._tvDeck = tvDeck;\n-    // Maintain a list of pinned channels.\n-    this.pinnedChannels = {};\n-    this.cardManager = new CardManager();\n-    this.cardManager.init('readonly')\n-                    .then(this.updatePinnedChannels.bind(this));\n+    this.isReady = false;\n+    this.currentTuners = {};\n+    this.playingState = {};\n+  }\n \n-    // Determine whether a card should be pinned or unpinned.\n-    document.addEventListener('contextmenu', this.updatePinButton.bind(this));\n+  var proto = Object.create(new evt());\n \n-    // Update pinnedChannels when card-list changed\n-    this.cardManager.on(\n-                'cardlist-changed', this.updatePinnedChannels.bind(this));\n-  }\n+  // Current hash\n+  Object.defineProperty(proto, 'currentHash', {\n+    get: function() {\n+      var state = this.playingState;\n+      return state.tunerId + ',' + state.sourceType + ',' + state.channelNumber;\n+    }\n+  });\n+\n+  proto.getTuner = function cm_getTuner(tunerId) {\n+    tunerId = tunerId || this.playingState.tunerId;\n+    return this.currentTuners[tunerId];\n+  };\n+\n+  proto.getSource = function cm_getSource(sourceType) {\n+    sourceType = sourceType || this.playingState.sourceType;\n+    var tuner = this.getTuner();\n+    if (!tuner || !tuner.sources) {\n+      return null;\n+    }\n+    return tuner.sources[sourceType];\n+  };\n \n-  var proto = {};\n+  proto.getChannel = function cm_getChannel(channelNumber) {\n+    channelNumber = channelNumber || this.playingState.channelNumber;\n+    var source = this.getSource();\n+    if (!source || !source.channelIndexHash) {\n+      return null;\n+    }\n+    var index = source.channelIndexHash[channelNumber];\n+    return source.channels[index];\n+  };\n \n   /**\n-   * Retrieve latest TV card list from card manager and update pin button\n-   * information.\n+   * Fetch tuner, source and channel settings from URL hash. If URL hash is\n+   * empty, then fetch settings from localStorage.","path":"tv_apps/tv-deck/js/channel_manager.js","position":71,"original_position":71,"commit_id":"d624f7090e1dc53fc470b9b057d4206986f5644d","original_commit_id":"d624f7090e1dc53fc470b9b057d4206986f5644d","user":{"login":"huchengtw-moz","id":4318454,"avatar_url":"https://avatars.githubusercontent.com/u/4318454?v=3","gravatar_id":"","url":"https://api.github.com/users/huchengtw-moz","html_url":"https://github.com/huchengtw-moz","followers_url":"https://api.github.com/users/huchengtw-moz/followers","following_url":"https://api.github.com/users/huchengtw-moz/following{/other_user}","gists_url":"https://api.github.com/users/huchengtw-moz/gists{/gist_id}","starred_url":"https://api.github.com/users/huchengtw-moz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/huchengtw-moz/subscriptions","organizations_url":"https://api.github.com/users/huchengtw-moz/orgs","repos_url":"https://api.github.com/users/huchengtw-moz/repos","events_url":"https://api.github.com/users/huchengtw-moz/events{/privacy}","received_events_url":"https://api.github.com/users/huchengtw-moz/received_events","type":"User","site_admin":false},"body":"typo here, replace `localStorage` with `asyncStorage`","created_at":"2015-04-29T10:01:34Z","updated_at":"2015-04-29T10:01:34Z","html_url":"https://github.com/mozilla-b2g/gaia/pull/29736#discussion_r29323132","pull_request_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/29736","_links":{"self":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments/29323132"},"html":{"href":"https://github.com/mozilla-b2g/gaia/pull/29736#discussion_r29323132"},"pull_request":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/29736"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/29736","id":34149381,"html_url":"https://github.com/mozilla-b2g/gaia/pull/29736","diff_url":"https://github.com/mozilla-b2g/gaia/pull/29736.diff","patch_url":"https://github.com/mozilla-b2g/gaia/pull/29736.patch","issue_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues/29736","number":29736,"state":"open","locked":false,"title":"Bug 1156183 - [Stingray][TvDeck] Move TVManager related API to ChannelMa...","user":{"login":"sean2449","id":6240413,"avatar_url":"https://avatars.githubusercontent.com/u/6240413?v=3","gravatar_id":"","url":"https://api.github.com/users/sean2449","html_url":"https://github.com/sean2449","followers_url":"https://api.github.com/users/sean2449/followers","following_url":"https://api.github.com/users/sean2449/following{/other_user}","gists_url":"https://api.github.com/users/sean2449/gists{/gist_id}","starred_url":"https://api.github.com/users/sean2449/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sean2449/subscriptions","organizations_url":"https://api.github.com/users/sean2449/orgs","repos_url":"https://api.github.com/users/sean2449/repos","events_url":"https://api.github.com/users/sean2449/events{/privacy}","received_events_url":"https://api.github.com/users/sean2449/received_events","type":"User","site_admin":false},"body":"...nager","created_at":"2015-04-27T08:46:10Z","updated_at":"2015-04-29T10:01:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6578e5bb833f5716b97f03fd56cf4bc16ddc5deb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/29736/commits","review_comments_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/29736/comments","review_comment_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues/29736/comments","statuses_url":"https://api.github.com/repos/mozilla-b2g/gaia/statuses/d624f7090e1dc53fc470b9b057d4206986f5644d","head":{"label":"sean2449:Bug_1156183-move-channel","ref":"Bug_1156183-move-channel","sha":"d624f7090e1dc53fc470b9b057d4206986f5644d","user":{"login":"sean2449","id":6240413,"avatar_url":"https://avatars.githubusercontent.com/u/6240413?v=3","gravatar_id":"","url":"https://api.github.com/users/sean2449","html_url":"https://github.com/sean2449","followers_url":"https://api.github.com/users/sean2449/followers","following_url":"https://api.github.com/users/sean2449/following{/other_user}","gists_url":"https://api.github.com/users/sean2449/gists{/gist_id}","starred_url":"https://api.github.com/users/sean2449/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sean2449/subscriptions","organizations_url":"https://api.github.com/users/sean2449/orgs","repos_url":"https://api.github.com/users/sean2449/repos","events_url":"https://api.github.com/users/sean2449/events{/privacy}","received_events_url":"https://api.github.com/users/sean2449/received_events","type":"User","site_admin":false},"repo":{"id":29124255,"name":"gaia","full_name":"sean2449/gaia","owner":{"login":"sean2449","id":6240413,"avatar_url":"https://avatars.githubusercontent.com/u/6240413?v=3","gravatar_id":"","url":"https://api.github.com/users/sean2449","html_url":"https://github.com/sean2449","followers_url":"https://api.github.com/users/sean2449/followers","following_url":"https://api.github.com/users/sean2449/following{/other_user}","gists_url":"https://api.github.com/users/sean2449/gists{/gist_id}","starred_url":"https://api.github.com/users/sean2449/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sean2449/subscriptions","organizations_url":"https://api.github.com/users/sean2449/orgs","repos_url":"https://api.github.com/users/sean2449/repos","events_url":"https://api.github.com/users/sean2449/events{/privacy}","received_events_url":"https://api.github.com/users/sean2449/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sean2449/gaia","description":"Gaia is a HTML5-based Phone UI for the Boot 2 Gecko Project. NOTE: For details of what branches are used for what releases, see","fork":true,"url":"https://api.github.com/repos/sean2449/gaia","forks_url":"https://api.github.com/repos/sean2449/gaia/forks","keys_url":"https://api.github.com/repos/sean2449/gaia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sean2449/gaia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sean2449/gaia/teams","hooks_url":"https://api.github.com/repos/sean2449/gaia/hooks","issue_events_url":"https://api.github.com/repos/sean2449/gaia/issues/events{/number}","events_url":"https://api.github.com/repos/sean2449/gaia/events","assignees_url":"https://api.github.com/repos/sean2449/gaia/assignees{/user}","branches_url":"https://api.github.com/repos/sean2449/gaia/branches{/branch}","tags_url":"https://api.github.com/repos/sean2449/gaia/tags","blobs_url":"https://api.github.com/repos/sean2449/gaia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sean2449/gaia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sean2449/gaia/git/refs{/sha}","trees_url":"https://api.github.com/repos/sean2449/gaia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sean2449/gaia/statuses/{sha}","languages_url":"https://api.github.com/repos/sean2449/gaia/languages","stargazers_url":"https://api.github.com/repos/sean2449/gaia/stargazers","contributors_url":"https://api.github.com/repos/sean2449/gaia/contributors","subscribers_url":"https://api.github.com/repos/sean2449/gaia/subscribers","subscription_url":"https://api.github.com/repos/sean2449/gaia/subscription","commits_url":"https://api.github.com/repos/sean2449/gaia/commits{/sha}","git_commits_url":"https://api.github.com/repos/sean2449/gaia/git/commits{/sha}","comments_url":"https://api.github.com/repos/sean2449/gaia/comments{/number}","issue_comment_url":"https://api.github.com/repos/sean2449/gaia/issues/comments{/number}","contents_url":"https://api.github.com/repos/sean2449/gaia/contents/{+path}","compare_url":"https://api.github.com/repos/sean2449/gaia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sean2449/gaia/merges","archive_url":"https://api.github.com/repos/sean2449/gaia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sean2449/gaia/downloads","issues_url":"https://api.github.com/repos/sean2449/gaia/issues{/number}","pulls_url":"https://api.github.com/repos/sean2449/gaia/pulls{/number}","milestones_url":"https://api.github.com/repos/sean2449/gaia/milestones{/number}","notifications_url":"https://api.github.com/repos/sean2449/gaia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sean2449/gaia/labels{/name}","releases_url":"https://api.github.com/repos/sean2449/gaia/releases{/id}","created_at":"2015-01-12T07:39:26Z","updated_at":"2015-04-21T09:59:31Z","pushed_at":"2015-04-29T08:17:34Z","git_url":"git://github.com/sean2449/gaia.git","ssh_url":"git@github.com:sean2449/gaia.git","clone_url":"https://github.com/sean2449/gaia.git","svn_url":"https://github.com/sean2449/gaia","homepage":"https://wiki.mozilla.org/B2G","size":914048,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mozilla-b2g:master","ref":"master","sha":"1bf37ff2a500f91249b51cb986aace60a397ccb9","user":{"login":"mozilla-b2g","id":1261292,"avatar_url":"https://avatars.githubusercontent.com/u/1261292?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla-b2g","html_url":"https://github.com/mozilla-b2g","followers_url":"https://api.github.com/users/mozilla-b2g/followers","following_url":"https://api.github.com/users/mozilla-b2g/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-b2g/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-b2g/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-b2g/subscriptions","organizations_url":"https://api.github.com/users/mozilla-b2g/orgs","repos_url":"https://api.github.com/users/mozilla-b2g/repos","events_url":"https://api.github.com/users/mozilla-b2g/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-b2g/received_events","type":"Organization","site_admin":false},"repo":{"id":2317369,"name":"gaia","full_name":"mozilla-b2g/gaia","owner":{"login":"mozilla-b2g","id":1261292,"avatar_url":"https://avatars.githubusercontent.com/u/1261292?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla-b2g","html_url":"https://github.com/mozilla-b2g","followers_url":"https://api.github.com/users/mozilla-b2g/followers","following_url":"https://api.github.com/users/mozilla-b2g/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-b2g/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-b2g/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-b2g/subscriptions","organizations_url":"https://api.github.com/users/mozilla-b2g/orgs","repos_url":"https://api.github.com/users/mozilla-b2g/repos","events_url":"https://api.github.com/users/mozilla-b2g/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-b2g/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla-b2g/gaia","description":"Gaia is a HTML5-based Phone UI for the Boot 2 Gecko Project. NOTE: For details of what branches are used for what releases, see","fork":false,"url":"https://api.github.com/repos/mozilla-b2g/gaia","forks_url":"https://api.github.com/repos/mozilla-b2g/gaia/forks","keys_url":"https://api.github.com/repos/mozilla-b2g/gaia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla-b2g/gaia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla-b2g/gaia/teams","hooks_url":"https://api.github.com/repos/mozilla-b2g/gaia/hooks","issue_events_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla-b2g/gaia/events","assignees_url":"https://api.github.com/repos/mozilla-b2g/gaia/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla-b2g/gaia/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla-b2g/gaia/tags","blobs_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla-b2g/gaia/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla-b2g/gaia/languages","stargazers_url":"https://api.github.com/repos/mozilla-b2g/gaia/stargazers","contributors_url":"https://api.github.com/repos/mozilla-b2g/gaia/contributors","subscribers_url":"https://api.github.com/repos/mozilla-b2g/gaia/subscribers","subscription_url":"https://api.github.com/repos/mozilla-b2g/gaia/subscription","commits_url":"https://api.github.com/repos/mozilla-b2g/gaia/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla-b2g/gaia/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla-b2g/gaia/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla-b2g/gaia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla-b2g/gaia/merges","archive_url":"https://api.github.com/repos/mozilla-b2g/gaia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla-b2g/gaia/downloads","issues_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla-b2g/gaia/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla-b2g/gaia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla-b2g/gaia/labels{/name}","releases_url":"https://api.github.com/repos/mozilla-b2g/gaia/releases{/id}","created_at":"2011-09-03T01:38:46Z","updated_at":"2015-04-28T23:09:03Z","pushed_at":"2015-04-29T09:59:51Z","git_url":"git://github.com/mozilla-b2g/gaia.git","ssh_url":"git@github.com:mozilla-b2g/gaia.git","clone_url":"https://github.com/mozilla-b2g/gaia.git","svn_url":"https://github.com/mozilla-b2g/gaia","homepage":"https://wiki.mozilla.org/B2G","size":1530110,"stargazers_count":1910,"watchers_count":1910,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2286,"mirror_url":null,"open_issues_count":984,"forks":2286,"open_issues":984,"watchers":1910,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/29736"},"html":{"href":"https://github.com/mozilla-b2g/gaia/pull/29736"},"issue":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/issues/29736"},"comments":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/issues/29736/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/29736/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/29736/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/statuses/d624f7090e1dc53fc470b9b057d4206986f5644d"}}}}