{"action":"created","comment":{"url":"https://api.github.com/repos/skillz/react-native-mentions/pulls/comments/168359867","pull_request_review_id":96713584,"id":168359867,"diff_hunk":"@@ -65,70 +63,355 @@ export class MentionsTextInput extends Component {\n     }).start();\n   }\n \n-  isTriggerDeleted(cursor) {\n-    return false;\n+  handleDisplaySuggestions(position) {\n+      if (!this.triggerMatrix || !this.triggerMatrix.length || !this.isTrackingStarted || this.shouldDeleteTriggerOnBackspace) {\n+        return;\n+      }\n+\n+      const keyword = this.getTriggerKeyword(position);\n+      const delay = this.props.triggerDelay ? this.props.triggerDelay : 0;\n+      if (keyword && keyword.length > delay) {\n+        if (this.props.triggerCallback) {\n+          this.props.triggerCallback(keyword, this.getSubsequentTriggerIndex(position), this.triggerMatrix);\n+        }\n+\n+        this.openSuggestionsPanel();\n+      } else {\n+        this.closeSuggestionsPanel();\n+      }\n+    }\n+\n+  handleDeleteTriggerOnBackspace(position = 0, index = -2) {\n+    if (!this.triggerMatrix || !this.triggerMatrix.length) {\n+      return;\n+    }\n+\n+    if (index === -2) {\n+      index = this.getSubsequentTriggerIndex(position);\n+    }\n+\n+    const isAtEnd = position === this.state.text.length - 1;\n+    const isAtEndOfTrigger = this.triggerMatrix[index][1] === position;\n+    const isFollowedBySpace = this.state.text[position + 1] === ' ';\n+\n+    this.shouldDeleteTriggerOnBackspace = (!this.isTrackingStarted && isAtEnd)\n+                                       || (isAtEndOfTrigger && (isAtEnd || isFollowedBySpace));\n   }\n \n-  handleTriggerDeletion(cursor) {\n+  handleClick(position) {\n+    if (!this.triggerMatrix || !this.triggerMatrix.length) {\n+      return;\n+    }\n+\n+    const index = this.getSubsequentTriggerIndex(position);\n+    this.handleDeleteTriggerOnBackspace(position, index);\n+\n+    if (this.isPositionWithinTrigger(position, index)) {\n+      this.startTracking(position, index);\n+      return;\n+    }\n+\n+    if (position === -1 || this.state.text && this.state.text[position] === ' ') {\n+      this.stopTracking();\n+    }\n   }\n \n-  updateSuggestions(lastKeyword) {\n-    this.props.triggerCallback(lastKeyword);\n+  handleTriggerSplitBySpace(position) {\n+    if (!this.triggerMatrix\n+          || !this.triggerMatrix.length\n+          || !this.isTrackingStarted\n+          || position < 1\n+          || position >= this.state.text.length) {\n+      return;\n+    }\n+\n+    const index = this.getSubsequentTriggerIndex(position);\n+    this.triggerMatrix[index][1] = position - 1;\n   }\n \n-  identifyKeyword(val) {\n-    if (this.isTrackingStarted) {\n-      const boundary = this.props.triggerLocation === 'new-word-only' ? 'B': '';\n-      const delay = this.props.triggerDelay ? this.props.triggerDelay : 0;\n-      const pattern = new RegExp(`\\\\${boundary}${this.props.trigger}[a-z0-9_-]{${delay},}`, `gi`);\n-      const keywordArray = val.match(pattern);\n-      if (keywordArray && !!keywordArray.length) {\n-        const lastKeyword = keywordArray[keywordArray.length - 1];\n-        this.updateSuggestions(lastKeyword);\n-        this.openSuggestionsPanel();\n-      } else {\n-        this.closeSuggestionsPanel();\n+  isTriggerSplitBySpace(position) {\n+    if (!this.triggerMatrix || !this.triggerMatrix.length) {\n+      return false;\n+    }\n+\n+    const index = this.getSubsequentTriggerIndex(position);\n+    return this.isPositionWithinTrigger(position, index)\n+              && this.isTrackingStarted\n+              && this.state.text[position] === ' ';","path":"index.js","position":133,"original_position":133,"commit_id":"d08f8eb5726ba1cfa2ac5bec81a807960faea9ff","original_commit_id":"d08f8eb5726ba1cfa2ac5bec81a807960faea9ff","user":{"login":"armandgray","id":20849388,"avatar_url":"https://avatars1.githubusercontent.com/u/20849388?v=4","gravatar_id":"","url":"https://api.github.com/users/armandgray","html_url":"https://github.com/armandgray","followers_url":"https://api.github.com/users/armandgray/followers","following_url":"https://api.github.com/users/armandgray/following{/other_user}","gists_url":"https://api.github.com/users/armandgray/gists{/gist_id}","starred_url":"https://api.github.com/users/armandgray/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/armandgray/subscriptions","organizations_url":"https://api.github.com/users/armandgray/orgs","repos_url":"https://api.github.com/users/armandgray/repos","events_url":"https://api.github.com/users/armandgray/events{/privacy}","received_events_url":"https://api.github.com/users/armandgray/received_events","type":"User","site_admin":false},"body":"👍 ","created_at":"2018-02-15T01:09:47Z","updated_at":"2018-02-15T01:09:47Z","html_url":"https://github.com/skillz/react-native-mentions/pull/3#discussion_r168359867","pull_request_url":"https://api.github.com/repos/skillz/react-native-mentions/pulls/3","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/skillz/react-native-mentions/pulls/comments/168359867"},"html":{"href":"https://github.com/skillz/react-native-mentions/pull/3#discussion_r168359867"},"pull_request":{"href":"https://api.github.com/repos/skillz/react-native-mentions/pulls/3"}},"in_reply_to_id":168359351},"pull_request":{"url":"https://api.github.com/repos/skillz/react-native-mentions/pulls/3","id":169262765,"html_url":"https://github.com/skillz/react-native-mentions/pull/3","diff_url":"https://github.com/skillz/react-native-mentions/pull/3.diff","patch_url":"https://github.com/skillz/react-native-mentions/pull/3.patch","issue_url":"https://api.github.com/repos/skillz/react-native-mentions/issues/3","number":3,"state":"open","locked":false,"title":"[#154345339][#155241059] Feature chat mentions upgrade","user":{"login":"armandgray","id":20849388,"avatar_url":"https://avatars1.githubusercontent.com/u/20849388?v=4","gravatar_id":"","url":"https://api.github.com/users/armandgray","html_url":"https://github.com/armandgray","followers_url":"https://api.github.com/users/armandgray/followers","following_url":"https://api.github.com/users/armandgray/following{/other_user}","gists_url":"https://api.github.com/users/armandgray/gists{/gist_id}","starred_url":"https://api.github.com/users/armandgray/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/armandgray/subscriptions","organizations_url":"https://api.github.com/users/armandgray/orgs","repos_url":"https://api.github.com/users/armandgray/repos","events_url":"https://api.github.com/users/armandgray/events{/privacy}","received_events_url":"https://api.github.com/users/armandgray/received_events","type":"User","site_admin":false},"body":"Functionality: \r\n1. Tracks the start and end indices of any and all @ mentions in the given textInput.\r\n2. Deletes any mention if the last char of the mention in deleted and there is a space after it or the cursor moved away from the mention.","created_at":"2018-02-15T00:57:45Z","updated_at":"2018-02-15T01:09:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bb51084f0ffefe01c008d9b689f1e39c4857391c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/skillz/react-native-mentions/pulls/3/commits","review_comments_url":"https://api.github.com/repos/skillz/react-native-mentions/pulls/3/comments","review_comment_url":"https://api.github.com/repos/skillz/react-native-mentions/pulls/comments{/number}","comments_url":"https://api.github.com/repos/skillz/react-native-mentions/issues/3/comments","statuses_url":"https://api.github.com/repos/skillz/react-native-mentions/statuses/d08f8eb5726ba1cfa2ac5bec81a807960faea9ff","head":{"label":"skillz:feature-chat-mentions-upgrade","ref":"feature-chat-mentions-upgrade","sha":"d08f8eb5726ba1cfa2ac5bec81a807960faea9ff","user":{"login":"skillz","id":2835552,"avatar_url":"https://avatars3.githubusercontent.com/u/2835552?v=4","gravatar_id":"","url":"https://api.github.com/users/skillz","html_url":"https://github.com/skillz","followers_url":"https://api.github.com/users/skillz/followers","following_url":"https://api.github.com/users/skillz/following{/other_user}","gists_url":"https://api.github.com/users/skillz/gists{/gist_id}","starred_url":"https://api.github.com/users/skillz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skillz/subscriptions","organizations_url":"https://api.github.com/users/skillz/orgs","repos_url":"https://api.github.com/users/skillz/repos","events_url":"https://api.github.com/users/skillz/events{/privacy}","received_events_url":"https://api.github.com/users/skillz/received_events","type":"Organization","site_admin":false},"repo":{"id":119446694,"name":"react-native-mentions","full_name":"skillz/react-native-mentions","owner":{"login":"skillz","id":2835552,"avatar_url":"https://avatars3.githubusercontent.com/u/2835552?v=4","gravatar_id":"","url":"https://api.github.com/users/skillz","html_url":"https://github.com/skillz","followers_url":"https://api.github.com/users/skillz/followers","following_url":"https://api.github.com/users/skillz/following{/other_user}","gists_url":"https://api.github.com/users/skillz/gists{/gist_id}","starred_url":"https://api.github.com/users/skillz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skillz/subscriptions","organizations_url":"https://api.github.com/users/skillz/orgs","repos_url":"https://api.github.com/users/skillz/repos","events_url":"https://api.github.com/users/skillz/events{/privacy}","received_events_url":"https://api.github.com/users/skillz/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/skillz/react-native-mentions","description":"Mentions textbox for React Native. Works on both ios and android. :tropical_fish: :whale: ","fork":true,"url":"https://api.github.com/repos/skillz/react-native-mentions","forks_url":"https://api.github.com/repos/skillz/react-native-mentions/forks","keys_url":"https://api.github.com/repos/skillz/react-native-mentions/keys{/key_id}","collaborators_url":"https://api.github.com/repos/skillz/react-native-mentions/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/skillz/react-native-mentions/teams","hooks_url":"https://api.github.com/repos/skillz/react-native-mentions/hooks","issue_events_url":"https://api.github.com/repos/skillz/react-native-mentions/issues/events{/number}","events_url":"https://api.github.com/repos/skillz/react-native-mentions/events","assignees_url":"https://api.github.com/repos/skillz/react-native-mentions/assignees{/user}","branches_url":"https://api.github.com/repos/skillz/react-native-mentions/branches{/branch}","tags_url":"https://api.github.com/repos/skillz/react-native-mentions/tags","blobs_url":"https://api.github.com/repos/skillz/react-native-mentions/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/skillz/react-native-mentions/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/skillz/react-native-mentions/git/refs{/sha}","trees_url":"https://api.github.com/repos/skillz/react-native-mentions/git/trees{/sha}","statuses_url":"https://api.github.com/repos/skillz/react-native-mentions/statuses/{sha}","languages_url":"https://api.github.com/repos/skillz/react-native-mentions/languages","stargazers_url":"https://api.github.com/repos/skillz/react-native-mentions/stargazers","contributors_url":"https://api.github.com/repos/skillz/react-native-mentions/contributors","subscribers_url":"https://api.github.com/repos/skillz/react-native-mentions/subscribers","subscription_url":"https://api.github.com/repos/skillz/react-native-mentions/subscription","commits_url":"https://api.github.com/repos/skillz/react-native-mentions/commits{/sha}","git_commits_url":"https://api.github.com/repos/skillz/react-native-mentions/git/commits{/sha}","comments_url":"https://api.github.com/repos/skillz/react-native-mentions/comments{/number}","issue_comment_url":"https://api.github.com/repos/skillz/react-native-mentions/issues/comments{/number}","contents_url":"https://api.github.com/repos/skillz/react-native-mentions/contents/{+path}","compare_url":"https://api.github.com/repos/skillz/react-native-mentions/compare/{base}...{head}","merges_url":"https://api.github.com/repos/skillz/react-native-mentions/merges","archive_url":"https://api.github.com/repos/skillz/react-native-mentions/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/skillz/react-native-mentions/downloads","issues_url":"https://api.github.com/repos/skillz/react-native-mentions/issues{/number}","pulls_url":"https://api.github.com/repos/skillz/react-native-mentions/pulls{/number}","milestones_url":"https://api.github.com/repos/skillz/react-native-mentions/milestones{/number}","notifications_url":"https://api.github.com/repos/skillz/react-native-mentions/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/skillz/react-native-mentions/labels{/name}","releases_url":"https://api.github.com/repos/skillz/react-native-mentions/releases{/id}","deployments_url":"https://api.github.com/repos/skillz/react-native-mentions/deployments","created_at":"2018-01-29T21:52:50Z","updated_at":"2018-01-29T21:52:52Z","pushed_at":"2018-02-15T00:57:45Z","git_url":"git://github.com/skillz/react-native-mentions.git","ssh_url":"git@github.com:skillz/react-native-mentions.git","clone_url":"https://github.com/skillz/react-native-mentions.git","svn_url":"https://github.com/skillz/react-native-mentions","homepage":"","size":3586,"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":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"skillz:skillz-0.0.4","ref":"skillz-0.0.4","sha":"3d4dbdc4b7713bc97292e416108054049f09ad25","user":{"login":"skillz","id":2835552,"avatar_url":"https://avatars3.githubusercontent.com/u/2835552?v=4","gravatar_id":"","url":"https://api.github.com/users/skillz","html_url":"https://github.com/skillz","followers_url":"https://api.github.com/users/skillz/followers","following_url":"https://api.github.com/users/skillz/following{/other_user}","gists_url":"https://api.github.com/users/skillz/gists{/gist_id}","starred_url":"https://api.github.com/users/skillz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skillz/subscriptions","organizations_url":"https://api.github.com/users/skillz/orgs","repos_url":"https://api.github.com/users/skillz/repos","events_url":"https://api.github.com/users/skillz/events{/privacy}","received_events_url":"https://api.github.com/users/skillz/received_events","type":"Organization","site_admin":false},"repo":{"id":119446694,"name":"react-native-mentions","full_name":"skillz/react-native-mentions","owner":{"login":"skillz","id":2835552,"avatar_url":"https://avatars3.githubusercontent.com/u/2835552?v=4","gravatar_id":"","url":"https://api.github.com/users/skillz","html_url":"https://github.com/skillz","followers_url":"https://api.github.com/users/skillz/followers","following_url":"https://api.github.com/users/skillz/following{/other_user}","gists_url":"https://api.github.com/users/skillz/gists{/gist_id}","starred_url":"https://api.github.com/users/skillz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skillz/subscriptions","organizations_url":"https://api.github.com/users/skillz/orgs","repos_url":"https://api.github.com/users/skillz/repos","events_url":"https://api.github.com/users/skillz/events{/privacy}","received_events_url":"https://api.github.com/users/skillz/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/skillz/react-native-mentions","description":"Mentions textbox for React Native. Works on both ios and android. :tropical_fish: :whale: ","fork":true,"url":"https://api.github.com/repos/skillz/react-native-mentions","forks_url":"https://api.github.com/repos/skillz/react-native-mentions/forks","keys_url":"https://api.github.com/repos/skillz/react-native-mentions/keys{/key_id}","collaborators_url":"https://api.github.com/repos/skillz/react-native-mentions/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/skillz/react-native-mentions/teams","hooks_url":"https://api.github.com/repos/skillz/react-native-mentions/hooks","issue_events_url":"https://api.github.com/repos/skillz/react-native-mentions/issues/events{/number}","events_url":"https://api.github.com/repos/skillz/react-native-mentions/events","assignees_url":"https://api.github.com/repos/skillz/react-native-mentions/assignees{/user}","branches_url":"https://api.github.com/repos/skillz/react-native-mentions/branches{/branch}","tags_url":"https://api.github.com/repos/skillz/react-native-mentions/tags","blobs_url":"https://api.github.com/repos/skillz/react-native-mentions/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/skillz/react-native-mentions/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/skillz/react-native-mentions/git/refs{/sha}","trees_url":"https://api.github.com/repos/skillz/react-native-mentions/git/trees{/sha}","statuses_url":"https://api.github.com/repos/skillz/react-native-mentions/statuses/{sha}","languages_url":"https://api.github.com/repos/skillz/react-native-mentions/languages","stargazers_url":"https://api.github.com/repos/skillz/react-native-mentions/stargazers","contributors_url":"https://api.github.com/repos/skillz/react-native-mentions/contributors","subscribers_url":"https://api.github.com/repos/skillz/react-native-mentions/subscribers","subscription_url":"https://api.github.com/repos/skillz/react-native-mentions/subscription","commits_url":"https://api.github.com/repos/skillz/react-native-mentions/commits{/sha}","git_commits_url":"https://api.github.com/repos/skillz/react-native-mentions/git/commits{/sha}","comments_url":"https://api.github.com/repos/skillz/react-native-mentions/comments{/number}","issue_comment_url":"https://api.github.com/repos/skillz/react-native-mentions/issues/comments{/number}","contents_url":"https://api.github.com/repos/skillz/react-native-mentions/contents/{+path}","compare_url":"https://api.github.com/repos/skillz/react-native-mentions/compare/{base}...{head}","merges_url":"https://api.github.com/repos/skillz/react-native-mentions/merges","archive_url":"https://api.github.com/repos/skillz/react-native-mentions/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/skillz/react-native-mentions/downloads","issues_url":"https://api.github.com/repos/skillz/react-native-mentions/issues{/number}","pulls_url":"https://api.github.com/repos/skillz/react-native-mentions/pulls{/number}","milestones_url":"https://api.github.com/repos/skillz/react-native-mentions/milestones{/number}","notifications_url":"https://api.github.com/repos/skillz/react-native-mentions/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/skillz/react-native-mentions/labels{/name}","releases_url":"https://api.github.com/repos/skillz/react-native-mentions/releases{/id}","deployments_url":"https://api.github.com/repos/skillz/react-native-mentions/deployments","created_at":"2018-01-29T21:52:50Z","updated_at":"2018-01-29T21:52:52Z","pushed_at":"2018-02-15T00:57:45Z","git_url":"git://github.com/skillz/react-native-mentions.git","ssh_url":"git@github.com:skillz/react-native-mentions.git","clone_url":"https://github.com/skillz/react-native-mentions.git","svn_url":"https://github.com/skillz/react-native-mentions","homepage":"","size":3586,"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":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/skillz/react-native-mentions/pulls/3"},"html":{"href":"https://github.com/skillz/react-native-mentions/pull/3"},"issue":{"href":"https://api.github.com/repos/skillz/react-native-mentions/issues/3"},"comments":{"href":"https://api.github.com/repos/skillz/react-native-mentions/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/skillz/react-native-mentions/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/skillz/react-native-mentions/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/skillz/react-native-mentions/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/skillz/react-native-mentions/statuses/d08f8eb5726ba1cfa2ac5bec81a807960faea9ff"}},"author_association":"NONE"}}
{"actor":{"display_login":"armandgray"}}