{"action":"created","comment":{"url":"https://api.github.com/repos/leancloud/js-realtime-sdk/pulls/comments/34333898","id":34333898,"diff_hunk":"@@ -381,26 +381,41 @@ void function(win) {\n                 if (!cache.openFlag) {\n                     throw('Must call after open() has successed.');\n                 }\n-                var convObject = newConvObject(cache);\n+\n+                var convObject;\n+\n                 // 传入 convId\n                 if (typeof argument === 'string') {\n-                    // cache.convIndex[convObject.id] = convObject;\n+                    var convId = argument;\n+\n+                    // 优先使用 cache 中的 conv\n+                    if (cache.conv[convId]) {\n+                        convObject = cache.conv[convId];\n+                    }\n+                    else {\n+                        convObject = newConvObject(cache);\n+                    }\n \n                     // 去服务器端判断下当前 room id 是否存在\n                     this.query({\n                         where: {\n-                            objectId: argument\n+                            objectId: convId\n                         }\n                     }, function(data) {\n \n                         // 如果服务器端有这个 id\n                         if (data.length) {\n-                            convObject.id = argument;\n+                            convObject.id = convId;\n                             convObject.name = data[0].name;\n                             // 获取初始化时的属性\n                             convObject.attr = data[0].attr;\n                         }\n \n+                        if (data.length) {\n+                            // 将 conv 写入 cache","path":"src/AV.realtime.js","position":50,"original_position":50,"commit_id":"2d6e5949909f9afdfa49dac2048092356ca660e4","original_commit_id":"2d6e5949909f9afdfa49dac2048092356ca660e4","user":{"login":"wangxiao","id":558368,"avatar_url":"https://avatars.githubusercontent.com/u/558368?v=3","gravatar_id":"","url":"https://api.github.com/users/wangxiao","html_url":"https://github.com/wangxiao","followers_url":"https://api.github.com/users/wangxiao/followers","following_url":"https://api.github.com/users/wangxiao/following{/other_user}","gists_url":"https://api.github.com/users/wangxiao/gists{/gist_id}","starred_url":"https://api.github.com/users/wangxiao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wangxiao/subscriptions","organizations_url":"https://api.github.com/users/wangxiao/orgs","repos_url":"https://api.github.com/users/wangxiao/repos","events_url":"https://api.github.com/users/wangxiao/events{/privacy}","received_events_url":"https://api.github.com/users/wangxiao/received_events","type":"User","site_admin":false},"body":"可以直接写在上面的判断中？","created_at":"2015-07-10T07:50:43Z","updated_at":"2015-07-10T07:50:43Z","html_url":"https://github.com/leancloud/js-realtime-sdk/pull/127#discussion_r34333898","pull_request_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/pulls/127","_links":{"self":{"href":"https://api.github.com/repos/leancloud/js-realtime-sdk/pulls/comments/34333898"},"html":{"href":"https://github.com/leancloud/js-realtime-sdk/pull/127#discussion_r34333898"},"pull_request":{"href":"https://api.github.com/repos/leancloud/js-realtime-sdk/pulls/127"}}},"pull_request":{"url":"https://api.github.com/repos/leancloud/js-realtime-sdk/pulls/127","id":39557433,"html_url":"https://github.com/leancloud/js-realtime-sdk/pull/127","diff_url":"https://github.com/leancloud/js-realtime-sdk/pull/127.diff","patch_url":"https://github.com/leancloud/js-realtime-sdk/pull/127.patch","issue_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/issues/127","number":127,"state":"open","locked":false,"title":"[chore] cache convObject, close #111.","user":{"login":"leeyeh","id":175227,"avatar_url":"https://avatars.githubusercontent.com/u/175227?v=3","gravatar_id":"","url":"https://api.github.com/users/leeyeh","html_url":"https://github.com/leeyeh","followers_url":"https://api.github.com/users/leeyeh/followers","following_url":"https://api.github.com/users/leeyeh/following{/other_user}","gists_url":"https://api.github.com/users/leeyeh/gists{/gist_id}","starred_url":"https://api.github.com/users/leeyeh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leeyeh/subscriptions","organizations_url":"https://api.github.com/users/leeyeh/orgs","repos_url":"https://api.github.com/users/leeyeh/repos","events_url":"https://api.github.com/users/leeyeh/events{/privacy}","received_events_url":"https://api.github.com/users/leeyeh/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-07-09T08:06:54Z","updated_at":"2015-07-10T07:50:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6205ce752191c3b35adfe077a4a7ce4d1f82b815","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/pulls/127/commits","review_comments_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/pulls/127/comments","review_comment_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/pulls/comments{/number}","comments_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/issues/127/comments","statuses_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/statuses/2d6e5949909f9afdfa49dac2048092356ca660e4","head":{"label":"leeyeh:convObj-cache","ref":"convObj-cache","sha":"2d6e5949909f9afdfa49dac2048092356ca660e4","user":{"login":"leeyeh","id":175227,"avatar_url":"https://avatars.githubusercontent.com/u/175227?v=3","gravatar_id":"","url":"https://api.github.com/users/leeyeh","html_url":"https://github.com/leeyeh","followers_url":"https://api.github.com/users/leeyeh/followers","following_url":"https://api.github.com/users/leeyeh/following{/other_user}","gists_url":"https://api.github.com/users/leeyeh/gists{/gist_id}","starred_url":"https://api.github.com/users/leeyeh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leeyeh/subscriptions","organizations_url":"https://api.github.com/users/leeyeh/orgs","repos_url":"https://api.github.com/users/leeyeh/repos","events_url":"https://api.github.com/users/leeyeh/events{/privacy}","received_events_url":"https://api.github.com/users/leeyeh/received_events","type":"User","site_admin":false},"repo":{"id":38728698,"name":"js-realtime-sdk","full_name":"leeyeh/js-realtime-sdk","owner":{"login":"leeyeh","id":175227,"avatar_url":"https://avatars.githubusercontent.com/u/175227?v=3","gravatar_id":"","url":"https://api.github.com/users/leeyeh","html_url":"https://github.com/leeyeh","followers_url":"https://api.github.com/users/leeyeh/followers","following_url":"https://api.github.com/users/leeyeh/following{/other_user}","gists_url":"https://api.github.com/users/leeyeh/gists{/gist_id}","starred_url":"https://api.github.com/users/leeyeh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leeyeh/subscriptions","organizations_url":"https://api.github.com/users/leeyeh/orgs","repos_url":"https://api.github.com/users/leeyeh/repos","events_url":"https://api.github.com/users/leeyeh/events{/privacy}","received_events_url":"https://api.github.com/users/leeyeh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/leeyeh/js-realtime-sdk","description":"LeanCloud Realtime Message JavaScript SDK","fork":true,"url":"https://api.github.com/repos/leeyeh/js-realtime-sdk","forks_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/forks","keys_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/teams","hooks_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/hooks","issue_events_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/issues/events{/number}","events_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/events","assignees_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/assignees{/user}","branches_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/branches{/branch}","tags_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/tags","blobs_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/git/refs{/sha}","trees_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/statuses/{sha}","languages_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/languages","stargazers_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/stargazers","contributors_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/contributors","subscribers_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/subscribers","subscription_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/subscription","commits_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/commits{/sha}","git_commits_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/git/commits{/sha}","comments_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/comments{/number}","issue_comment_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/issues/comments{/number}","contents_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/contents/{+path}","compare_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/merges","archive_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/downloads","issues_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/issues{/number}","pulls_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/pulls{/number}","milestones_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/milestones{/number}","notifications_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/labels{/name}","releases_url":"https://api.github.com/repos/leeyeh/js-realtime-sdk/releases{/id}","created_at":"2015-07-08T03:05:16Z","updated_at":"2015-07-08T03:05:17Z","pushed_at":"2015-07-09T10:04:12Z","git_url":"git://github.com/leeyeh/js-realtime-sdk.git","ssh_url":"git@github.com:leeyeh/js-realtime-sdk.git","clone_url":"https://github.com/leeyeh/js-realtime-sdk.git","svn_url":"https://github.com/leeyeh/js-realtime-sdk","homepage":null,"size":1030,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"leancloud:master","ref":"master","sha":"54ac870269f313a5dbc84d020f5ae5b67dab8e58","user":{"login":"leancloud","id":6660518,"avatar_url":"https://avatars.githubusercontent.com/u/6660518?v=3","gravatar_id":"","url":"https://api.github.com/users/leancloud","html_url":"https://github.com/leancloud","followers_url":"https://api.github.com/users/leancloud/followers","following_url":"https://api.github.com/users/leancloud/following{/other_user}","gists_url":"https://api.github.com/users/leancloud/gists{/gist_id}","starred_url":"https://api.github.com/users/leancloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leancloud/subscriptions","organizations_url":"https://api.github.com/users/leancloud/orgs","repos_url":"https://api.github.com/users/leancloud/repos","events_url":"https://api.github.com/users/leancloud/events{/privacy}","received_events_url":"https://api.github.com/users/leancloud/received_events","type":"Organization","site_admin":false},"repo":{"id":29335461,"name":"js-realtime-sdk","full_name":"leancloud/js-realtime-sdk","owner":{"login":"leancloud","id":6660518,"avatar_url":"https://avatars.githubusercontent.com/u/6660518?v=3","gravatar_id":"","url":"https://api.github.com/users/leancloud","html_url":"https://github.com/leancloud","followers_url":"https://api.github.com/users/leancloud/followers","following_url":"https://api.github.com/users/leancloud/following{/other_user}","gists_url":"https://api.github.com/users/leancloud/gists{/gist_id}","starred_url":"https://api.github.com/users/leancloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leancloud/subscriptions","organizations_url":"https://api.github.com/users/leancloud/orgs","repos_url":"https://api.github.com/users/leancloud/repos","events_url":"https://api.github.com/users/leancloud/events{/privacy}","received_events_url":"https://api.github.com/users/leancloud/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/leancloud/js-realtime-sdk","description":"LeanCloud Realtime Message JavaScript SDK","fork":false,"url":"https://api.github.com/repos/leancloud/js-realtime-sdk","forks_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/forks","keys_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/teams","hooks_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/hooks","issue_events_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/issues/events{/number}","events_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/events","assignees_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/assignees{/user}","branches_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/branches{/branch}","tags_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/tags","blobs_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/git/refs{/sha}","trees_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/statuses/{sha}","languages_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/languages","stargazers_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/stargazers","contributors_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/contributors","subscribers_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/subscribers","subscription_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/subscription","commits_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/commits{/sha}","git_commits_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/git/commits{/sha}","comments_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/comments{/number}","issue_comment_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/issues/comments{/number}","contents_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/contents/{+path}","compare_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/merges","archive_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/downloads","issues_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/issues{/number}","pulls_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/pulls{/number}","milestones_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/milestones{/number}","notifications_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/labels{/name}","releases_url":"https://api.github.com/repos/leancloud/js-realtime-sdk/releases{/id}","created_at":"2015-01-16T06:13:58Z","updated_at":"2015-07-10T06:16:08Z","pushed_at":"2015-07-09T08:06:55Z","git_url":"git://github.com/leancloud/js-realtime-sdk.git","ssh_url":"git@github.com:leancloud/js-realtime-sdk.git","clone_url":"https://github.com/leancloud/js-realtime-sdk.git","svn_url":"https://github.com/leancloud/js-realtime-sdk","homepage":null,"size":1030,"stargazers_count":30,"watchers_count":30,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":16,"mirror_url":null,"open_issues_count":13,"forks":16,"open_issues":13,"watchers":30,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/leancloud/js-realtime-sdk/pulls/127"},"html":{"href":"https://github.com/leancloud/js-realtime-sdk/pull/127"},"issue":{"href":"https://api.github.com/repos/leancloud/js-realtime-sdk/issues/127"},"comments":{"href":"https://api.github.com/repos/leancloud/js-realtime-sdk/issues/127/comments"},"review_comments":{"href":"https://api.github.com/repos/leancloud/js-realtime-sdk/pulls/127/comments"},"review_comment":{"href":"https://api.github.com/repos/leancloud/js-realtime-sdk/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/leancloud/js-realtime-sdk/pulls/127/commits"},"statuses":{"href":"https://api.github.com/repos/leancloud/js-realtime-sdk/statuses/2d6e5949909f9afdfa49dac2048092356ca660e4"}}}}