diff options
Diffstat (limited to 'web/react/utils')
-rw-r--r-- | web/react/utils/async_client.jsx | 24 | ||||
-rw-r--r-- | web/react/utils/client.jsx | 31 | ||||
-rw-r--r-- | web/react/utils/constants.jsx | 3 | ||||
-rw-r--r-- | web/react/utils/utils.jsx | 11 |
4 files changed, 62 insertions, 7 deletions
diff --git a/web/react/utils/async_client.jsx b/web/react/utils/async_client.jsx index bb7ca458f..9383057c3 100644 --- a/web/react/utils/async_client.jsx +++ b/web/react/utils/async_client.jsx @@ -15,6 +15,8 @@ var ActionTypes = Constants.ActionTypes; var callTracker = {}; var dispatchError = function(err, method) { + if (err.message === "There appears to be a problem with your internet connection") return; + AppDispatcher.handleServerAction({ type: ActionTypes.RECIEVED_ERROR, err: err, @@ -355,3 +357,25 @@ module.exports.getStatuses = function() { } ); } + +module.exports.getMyTeam = function() { + if (isCallInProgress("getMyTeam")) return; + + callTracker["getMyTeam"] = utils.getTimestamp(); + client.getMyTeam( + function(data, textStatus, xhr) { + callTracker["getMyTeam"] = 0; + + if (xhr.status === 304 || !data) return; + + AppDispatcher.handleServerAction({ + type: ActionTypes.RECIEVED_TEAM, + team: data + }); + }, + function(err) { + callTracker["getMyTeam"] = 0; + dispatchError(err, "getMyTeam"); + } + ); +} diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx index 786e6dcea..15b6ace91 100644 --- a/web/react/utils/client.jsx +++ b/web/react/utils/client.jsx @@ -811,3 +811,34 @@ module.exports.getStatuses = function(success, error) { } }); }; + +module.exports.getMyTeam = function(success, error) { + $.ajax({ + url: "/api/v1/teams/me", + dataType: 'json', + type: 'GET', + success: success, + ifModified: true, + error: function(xhr, status, err) { + e = handleError("getMyTeam", xhr, status, err); + error(e); + } + }); +}; + +module.exports.updateValetFeature = function(data, success, error) { + $.ajax({ + url: "/api/v1/teams/update_valet_feature", + dataType: 'json', + contentType: 'application/json', + type: 'POST', + data: JSON.stringify(data), + success: success, + error: function(xhr, status, err) { + e = handleError("updateValetFeature", xhr, status, err); + error(e); + } + }); + + module.exports.track('api', 'api_teams_update_valet_feature'); +}; diff --git a/web/react/utils/constants.jsx b/web/react/utils/constants.jsx index deb07409b..4a0d243e2 100644 --- a/web/react/utils/constants.jsx +++ b/web/react/utils/constants.jsx @@ -27,6 +27,9 @@ module.exports = { RECIEVED_STATUSES: null, RECIEVED_MSG: null, + + CLICK_TEAM: null, + RECIEVED_TEAM: null, }), PayloadSources: keyMirror({ diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx index 0a0812c42..75c583c8f 100644 --- a/web/react/utils/utils.jsx +++ b/web/react/utils/utils.jsx @@ -381,9 +381,6 @@ module.exports.textToJsx = function(text, options) { if (options && options['singleline']) { var repRegex = new RegExp("\n", "g"); text = text.replace(repRegex, " "); - } else { - var repRegex = new RegExp("\n", "g"); - text = text.replace(repRegex, "<br>"); } var searchTerm = "" @@ -407,7 +404,7 @@ module.exports.textToJsx = function(text, options) { implicitKeywords[keywordArray[i]] = true; } - var lines = text.split("<br>"); + var lines = text.split("\n"); var urlMatcher = new LinkifyIt(); for (var i = 0; i < lines.length; i++) { var line = lines[i]; @@ -436,7 +433,7 @@ module.exports.textToJsx = function(text, options) { highlightSearchClass = " search-highlight"; } - inner.push(<span key={name+i+z+"_span"}>{prefix}<a className={mClass + highlightSearchClass + " mention-link"} key={name+i+z+"_link"} href="#" onClick={function() {module.exports.searchForTerm(name);}}>@{name}</a>{suffix} </span>); + inner.push(<span key={name+i+z+"_span"}>{prefix}<a className={mClass + highlightSearchClass + " mention-link"} key={name+i+z+"_link"} href="#" onClick={function(value) { return function() { module.exports.searchForTerm(value); } }(name)}>@{name}</a>{suffix} </span>); } else if (urlMatcher.test(word)) { var match = urlMatcher.match(word)[0]; var link = match.url; @@ -449,7 +446,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 ? mentionClass : ""; + var mClass = trimWord in implicitKeywords || trimWord.toLowerCase() in implicitKeywords ? mentionClass : ""; if (searchTerm === trimWord.substring(1).toLowerCase() || searchTerm === trimWord.toLowerCase()) { highlightSearchClass = " search-highlight"; @@ -457,7 +454,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) { + } else if (trimWord in implicitKeywords || trimWord.toLowerCase() in implicitKeywords) { var suffix = word.match(puncEndRegex); var prefix = word.match(puncStartRegex); |