From f030476ff5f438b96d7282c37ad7a42ffc61ae85 Mon Sep 17 00:00:00 2001
From: JoramWilander <jwawilander@gmail.com>
Date: Tue, 30 Jun 2015 09:06:10 -0400
Subject: @all and @channel now highlight like other mentions

---
 web/react/utils/utils.jsx | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

(limited to 'web/react/utils/utils.jsx')

diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index 75c583c8f..d50a044bc 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -421,10 +421,13 @@ module.exports.textToJsx = function(text, options) {
                 highlightSearchClass = " search-highlight";
             }
 
-            if (explicitMention && UserStore.getProfileByUsername(explicitMention[1])) {
+            if (explicitMention &&
+                (UserStore.getProfileByUsername(explicitMention[1]) ||
+                Constants.SPECIAL_MENTIONS.indexOf(explicitMention[1]) !== -1))
+            {
                 var name = explicitMention[1];
                 // do both a non-case sensitive and case senstive check
-                var mClass = (name.toLowerCase() in implicitKeywords || name in implicitKeywords) ? mentionClass : "";
+                var mClass = (('@'+name.toLowerCase()) in implicitKeywords || ('@'+name) in implicitKeywords) ? mentionClass : "";
 
                 var suffix = word.match(puncEndRegex);
                 var prefix = word.match(puncStartRegex);
-- 
cgit v1.2.3-1-g7c22


From bcc31b714b19ff3817c96c801028e23ace8cc55b Mon Sep 17 00:00:00 2001
From: nickago <ngonella@calpoly.edu>
Date: Tue, 30 Jun 2015 11:56:55 -0700
Subject: Added the ability to have hashtags with dashes in them

---
 web/react/utils/utils.jsx | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'web/react/utils/utils.jsx')

diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index d50a044bc..175fc2922 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -395,8 +395,8 @@ module.exports.textToJsx = function(text, options) {
 
     var inner = [];
 
-    // Function specific regexes
-    var hashRegex = /^href="#[^"]+"|(#[A-Za-z]+[A-Za-z0-9_]*[A-Za-z0-9])$/g;
+    // Function specific regex
+    var hashRegex = /^href="#[^"]+"|(#[A-Za-z]+[A-Za-z0-9_\-]*[A-Za-z0-9])$/g;
 
     var implicitKeywords = {};
     var keywordArray = UserStore.getCurrentMentionKeys();
-- 
cgit v1.2.3-1-g7c22


From ae77db2145684e6d6db2b120c248279b55c5e407 Mon Sep 17 00:00:00 2001
From: Reed Garmsen <rgarmsen2295@gmail.com>
Date: Tue, 30 Jun 2015 12:30:11 -0700
Subject: Changed keyword logic to use arrays rather than maps to remove
 highlighting of js object properties like constructor and __proto__

---
 web/react/utils/utils.jsx | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

(limited to 'web/react/utils/utils.jsx')

diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index d50a044bc..84bcc284d 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -398,10 +398,10 @@ module.exports.textToJsx = function(text, options) {
     // Function specific regexes
     var hashRegex = /^href="#[^"]+"|(#[A-Za-z]+[A-Za-z0-9_]*[A-Za-z0-9])$/g;
 
-    var implicitKeywords = {};
+    var implicitKeywords = [];
     var keywordArray = UserStore.getCurrentMentionKeys();
     for (var i = 0; i < keywordArray.length; i++) {
-        implicitKeywords[keywordArray[i]] = true;
+        implicitKeywords[i] = keywordArray[i];
     }
 
     var lines = text.split("\n");
@@ -427,7 +427,7 @@ module.exports.textToJsx = function(text, options) {
             {
                 var name = explicitMention[1];
                 // do both a non-case sensitive and case senstive check
-                var mClass = (('@'+name.toLowerCase()) in implicitKeywords || ('@'+name) in implicitKeywords) ? mentionClass : "";
+                var mClass = implicitKeywords.indexOf('@'+name.toLowerCase()) !== -1 || implicitKeywords.indexOf('@'+name) !== -1 ? mentionClass : "";
 
                 var suffix = word.match(puncEndRegex);
                 var prefix = word.match(puncStartRegex);
@@ -449,7 +449,7 @@ module.exports.textToJsx = function(text, options) {
             } else if (trimWord.match(hashRegex)) {
                 var suffix = word.match(puncEndRegex);
                 var prefix = word.match(puncStartRegex);
-                var mClass = trimWord in implicitKeywords || trimWord.toLowerCase() in implicitKeywords ? mentionClass : "";
+                var mClass = implicitKeywords.indexOf(trimWord) !== -1 || implicitKeywords.indexOf(trimWord.toLowerCase()) !== -1 ? mentionClass : "";
 
                 if (searchTerm === trimWord.substring(1).toLowerCase() || searchTerm === trimWord.toLowerCase()) {
                     highlightSearchClass = " search-highlight";
@@ -457,7 +457,7 @@ module.exports.textToJsx = function(text, options) {
 
                 inner.push(<span key={word+i+z+"_span"}>{prefix}<a key={word+i+z+"_hash"} className={"theme " + mClass + highlightSearchClass} href="#" onClick={function(value) { return function() { module.exports.searchForTerm(value); } }(trimWord)}>{trimWord}</a>{suffix} </span>);
 
-            } else if (trimWord in implicitKeywords || trimWord.toLowerCase() in implicitKeywords) {
+            } else if (implicitKeywords.indexOf(trimWord) !== -1 || implicitKeywords.indexOf(trimWord.toLowerCase()) !== -1) {
                 var suffix = word.match(puncEndRegex);
                 var prefix = word.match(puncStartRegex);
 
-- 
cgit v1.2.3-1-g7c22


From 71d0a9472f22e34c24bcdd61ce14748f5ca7ae43 Mon Sep 17 00:00:00 2001
From: Reed Garmsen <rgarmsen2295@gmail.com>
Date: Tue, 30 Jun 2015 15:00:57 -0700
Subject: Removed unnecessary loop copying

---
 web/react/utils/utils.jsx | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

(limited to 'web/react/utils/utils.jsx')

diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index 84bcc284d..08b83d084 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -398,11 +398,7 @@ module.exports.textToJsx = function(text, options) {
     // Function specific regexes
     var hashRegex = /^href="#[^"]+"|(#[A-Za-z]+[A-Za-z0-9_]*[A-Za-z0-9])$/g;
 
-    var implicitKeywords = [];
-    var keywordArray = UserStore.getCurrentMentionKeys();
-    for (var i = 0; i < keywordArray.length; i++) {
-        implicitKeywords[i] = keywordArray[i];
-    }
+    var implicitKeywords = UserStore.getCurrentMentionKeys();
 
     var lines = text.split("\n");
     var urlMatcher = new LinkifyIt();
-- 
cgit v1.2.3-1-g7c22


From fd310e382a2cc1a9779ef28dee7fea9476bb425f Mon Sep 17 00:00:00 2001
From: nickago <ngonella@calpoly.edu>
Date: Wed, 1 Jul 2015 12:41:36 -0700
Subject: Finally fixed the git weirdness

---
 web/react/utils/utils.jsx | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

(limited to 'web/react/utils/utils.jsx')

diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index 70a47742f..530166f04 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -2,6 +2,7 @@
 // See License.txt for license information.
 
 var AppDispatcher = require('../dispatcher/app_dispatcher.jsx');
+var ChannelStore = require('../stores/channel_store.jsx')
 var UserStore = require('../stores/user_store.jsx');
 var Constants = require('../utils/constants.jsx');
 var ActionTypes = Constants.ActionTypes;
@@ -726,6 +727,23 @@ module.exports.isComment = function(post) {
     return false;
 }
 
+module.exports.getDirectTeammate = function(channel_id) {
+  var userIds = ChannelStore.get(channel_id).name.split('__');
+
+  if(userIds.length != 2) {
+    return;
+  }
+
+  var curUser = UserStore.getCurrentId();
+
+  for(var idx in userIds) {
+    if(userIds[idx] === curUser)
+      delete userIds[idx];
+  }
+
+  return UserStore.getProfile(userIds[0])
+}
+
 Image.prototype.load = function(url, progressCallback) {
     var thisImg = this;
     var xmlHTTP = new XMLHttpRequest();
-- 
cgit v1.2.3-1-g7c22


From 7b6fe252f18b12107af105f9348da28f2f0d4a0c Mon Sep 17 00:00:00 2001
From: JoramWilander <jwawilander@gmail.com>
Date: Thu, 2 Jul 2015 09:32:31 -0400
Subject: fix getDirectTeammate so that if teammate is the second id it doesn't
 return null

---
 web/react/utils/utils.jsx | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

(limited to 'web/react/utils/utils.jsx')

diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index 530166f04..13cb0ff53 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -728,20 +728,22 @@ module.exports.isComment = function(post) {
 }
 
 module.exports.getDirectTeammate = function(channel_id) {
-  var userIds = ChannelStore.get(channel_id).name.split('__');
+    var userIds = ChannelStore.get(channel_id).name.split('__');
+    var curUserId = UserStore.getCurrentId();
+    var teammate = {};
 
-  if(userIds.length != 2) {
-    return;
-  }
-
-  var curUser = UserStore.getCurrentId();
+    if(userIds.length != 2 || userIds.indexOf(curUserId) === -1) {
+        return teammate;
+    }
 
-  for(var idx in userIds) {
-    if(userIds[idx] === curUser)
-      delete userIds[idx];
-  }
+    for (var idx = 0; idx < userIds.length; idx++) {
+        if(userIds[idx] !== curUserId) {
+            teammate = UserStore.getProfile(userIds[idx]);
+            break;
+        }
+    }
 
-  return UserStore.getProfile(userIds[0])
+    return teammate;
 }
 
 Image.prototype.load = function(url, progressCallback) {
-- 
cgit v1.2.3-1-g7c22


From 18629d8184a985d9fe9f9bf892952044b1e5d57f Mon Sep 17 00:00:00 2001
From: JoramWilander <jwawilander@gmail.com>
Date: Thu, 2 Jul 2015 09:34:57 -0400
Subject: make loop simpler

---
 web/react/utils/utils.jsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'web/react/utils/utils.jsx')

diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index 13cb0ff53..f8a7d6450 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -736,7 +736,7 @@ module.exports.getDirectTeammate = function(channel_id) {
         return teammate;
     }
 
-    for (var idx = 0; idx < userIds.length; idx++) {
+    for (var idx in userIds) {
         if(userIds[idx] !== curUserId) {
             teammate = UserStore.getProfile(userIds[idx]);
             break;
-- 
cgit v1.2.3-1-g7c22

