From 6f5e4a00588aefdda7a5a1cfe70935870e7e234a Mon Sep 17 00:00:00 2001 From: Bennett Date: Tue, 22 Sep 2020 20:56:48 +0200 Subject: Unpack recipes and update recipes icons (#292) Co-authored-by: Amine Mouafik --- recipes/mattermost/README.md | 5 +++++ recipes/mattermost/icon.png | Bin 0 -> 71150 bytes recipes/mattermost/icon.svg | 14 ++++++++++++++ recipes/mattermost/index.js | 20 ++++++++++++++++++++ recipes/mattermost/package.json | 14 ++++++++++++++ recipes/mattermost/webview.js | 14 ++++++++++++++ 6 files changed, 67 insertions(+) create mode 100644 recipes/mattermost/README.md create mode 100644 recipes/mattermost/icon.png create mode 100644 recipes/mattermost/icon.svg create mode 100644 recipes/mattermost/index.js create mode 100644 recipes/mattermost/package.json create mode 100644 recipes/mattermost/webview.js (limited to 'recipes/mattermost') diff --git a/recipes/mattermost/README.md b/recipes/mattermost/README.md new file mode 100644 index 0000000..3321fb5 --- /dev/null +++ b/recipes/mattermost/README.md @@ -0,0 +1,5 @@ +# Mattermost for Franz +This is the official Franz recipe for Mattermost + +### How to create your own Franz recipes: +* [Read the documentation](https://github.com/meetfranz/plugins) diff --git a/recipes/mattermost/icon.png b/recipes/mattermost/icon.png new file mode 100644 index 0000000..a98e65d Binary files /dev/null and b/recipes/mattermost/icon.png differ diff --git a/recipes/mattermost/icon.svg b/recipes/mattermost/icon.svg new file mode 100644 index 0000000..9f7056d --- /dev/null +++ b/recipes/mattermost/icon.svg @@ -0,0 +1,14 @@ + + + + mattermost + Created with Sketch. + + + + + + + + + \ No newline at end of file diff --git a/recipes/mattermost/index.js b/recipes/mattermost/index.js new file mode 100644 index 0000000..8f814fa --- /dev/null +++ b/recipes/mattermost/index.js @@ -0,0 +1,20 @@ +"use strict"; + +module.exports = Franz => class Mattermost extends Franz { + async validateUrl(url) { + try { + const resp = await window.fetch(url, { + method: 'GET', + headers: { + 'Content-Type': 'application/json' + } + }); + return resp.status.toString().startsWith('2'); + } catch (err) { + console.error(err); + } + + return false; + } + +}; \ No newline at end of file diff --git a/recipes/mattermost/package.json b/recipes/mattermost/package.json new file mode 100644 index 0000000..52a1908 --- /dev/null +++ b/recipes/mattermost/package.json @@ -0,0 +1,14 @@ +{ + "id": "mattermost", + "name": "Mattermost", + "version": "1.2.2", + "description": "Mattermost", + "main": "index.js", + "author": "Stefan Malzner ", + "license": "MIT", + "config": { + "hasNotificationSound": true, + "hasIndirectMessages": true, + "hasCustomUrl": true + } +} diff --git a/recipes/mattermost/webview.js b/recipes/mattermost/webview.js new file mode 100644 index 0000000..f348da4 --- /dev/null +++ b/recipes/mattermost/webview.js @@ -0,0 +1,14 @@ +"use strict"; + +module.exports = Franz => { + const getMessages = function getMessages() { + const directMessages = document.querySelectorAll('.sidebar--left .has-badge .badge').length; + const allMessages = document.querySelectorAll('.sidebar--left .has-badge').length - directMessages; + const channelMessages = document.querySelectorAll('.sidebar--left .unread-title').length - allMessages; + const teamDirectMessages = document.querySelectorAll('.team-wrapper .team-container .badge').length; + const teamMessages = document.querySelectorAll('.team-wrapper .unread').length - teamDirectMessages; + Franz.setBadge(directMessages + teamDirectMessages, allMessages + channelMessages + teamMessages); + }; + + Franz.loop(getMessages); +}; -- cgit v1.2.3-54-g00ecf