aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/hipchat
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/hipchat')
-rw-r--r--recipes/hipchat/index.js76
-rw-r--r--recipes/hipchat/package.json2
-rw-r--r--recipes/hipchat/webview.js12
3 files changed, 65 insertions, 25 deletions
diff --git a/recipes/hipchat/index.js b/recipes/hipchat/index.js
index ce3256b..e786bcb 100644
--- a/recipes/hipchat/index.js
+++ b/recipes/hipchat/index.js
@@ -1,27 +1,57 @@
1function _asyncToGenerator(fn) { return function () { const gen = Reflect.apply(fn, this, arguments); return new Promise((resolve, reject) => { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then((value) => { step('next', value); }, (error) => { step('throw', error); }); } } return step('next'); }); }; } 1function _asyncToGenerator(fn) {
2 return function () {
3 const gen = Reflect.apply(fn, this, arguments);
4 return new Promise((resolve, reject) => {
5 function step(key, arg) {
6 try {
7 var info = gen[key](arg);
8 var value = info.value;
9 } catch (error) {
10 reject(error);
11 return;
12 }
13 if (info.done) {
14 resolve(value);
15 } else {
16 // eslint-disable-next-line consistent-return
17 return Promise.resolve(value).then(
18 value => {
19 step('next', value);
20 },
21 error => {
22 step('throw', error);
23 },
24 );
25 }
26 }
27 return step('next');
28 });
29 };
30}
2 31
3module.exports = Ferdium => class HipChat extends Ferdium { 32module.exports = Ferdium =>
4 validateUrl(url) { 33 class HipChat extends Ferdium {
5 return _asyncToGenerator(function* () { 34 validateUrl(url) {
6 try { 35 return _asyncToGenerator(function* () {
7 const resp = yield window.fetch(`${url}/api/features`, { 36 try {
8 method: 'GET', 37 const resp = yield window.fetch(`${url}/api/features`, {
9 headers: { 38 method: 'GET',
10 'Content-Type': 'application/json', 39 headers: {
11 }, 40 'Content-Type': 'application/json',
12 }); 41 },
13 const data = yield resp.json(); 42 });
43 const data = yield resp.json();
14 44
15 return Object.hasOwnProperty.call(data, 'features'); 45 return Object.hasOwnProperty.call(data, 'features');
16 } catch (error) { 46 } catch (error) {
17 console.error(error); 47 console.error(error);
18 } 48 }
19 49
20 return false; 50 return false;
21 })(); 51 })();
22 } 52 }
23 53
24 buildUrl(url) { 54 buildUrl(url) {
25 return `${url}/chat`; 55 return `${url}/chat`;
26 } 56 }
27}; 57 };
diff --git a/recipes/hipchat/package.json b/recipes/hipchat/package.json
index 0be97cc..0f9f3f0 100644
--- a/recipes/hipchat/package.json
+++ b/recipes/hipchat/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "hipchat", 2 "id": "hipchat",
3 "name": "HipChat", 3 "name": "HipChat",
4 "version": "1.2.0", 4 "version": "1.3.0",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://{teamId}.hipchat.com/chat", 7 "serviceURL": "https://{teamId}.hipchat.com/chat",
diff --git a/recipes/hipchat/webview.js b/recipes/hipchat/webview.js
index 229b376..6871fbb 100644
--- a/recipes/hipchat/webview.js
+++ b/recipes/hipchat/webview.js
@@ -1,11 +1,21 @@
1function _interopRequireDefault(obj) {
2 return obj && obj.__esModule ? obj : { default: obj };
3}
4
5const _path = _interopRequireDefault(require('path'));
6
1module.exports = Ferdium => { 7module.exports = Ferdium => {
2 const getMessages = () => { 8 const getMessages = () => {
3 const directMessages = document.querySelectorAll('.hc-mention').length; 9 const directMessages = document.querySelectorAll('.hc-mention').length;
4 const allMessages = document.querySelectorAll('.aui-badge:not(.hc-mention)').length - directMessages; 10 const allMessages =
11 document.querySelectorAll('.aui-badge:not(.hc-mention)').length -
12 directMessages;
5 13
6 // set Ferdium badge 14 // set Ferdium badge
7 Ferdium.setBadge(directMessages, allMessages); 15 Ferdium.setBadge(directMessages, allMessages);
8 }; 16 };
9 17
10 Ferdium.loop(getMessages); 18 Ferdium.loop(getMessages);
19
20 Ferdium.injectCSS(_path.default.join(__dirname, 'service.css'));
11}; 21};