aboutsummaryrefslogtreecommitdiffstats
path: root/uncompressed/mastodon/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'uncompressed/mastodon/index.js')
-rw-r--r--uncompressed/mastodon/index.js53
1 files changed, 0 insertions, 53 deletions
diff --git a/uncompressed/mastodon/index.js b/uncompressed/mastodon/index.js
deleted file mode 100644
index a2ca0b7..0000000
--- a/uncompressed/mastodon/index.js
+++ /dev/null
@@ -1,53 +0,0 @@
1//'use strict';
2
3module.exports = Franz => class Mastodon extends Franz {
4
5 constructor(...args) {
6 let _temp;
7 //
8 let serviceCache = {};
9 // send service store for webview
10 setInterval(() => {
11 if (!window.franz) { // not present(near equal not initialize)
12 return;
13 }
14 const services = window.franz.stores.services;
15 // filter this recipe class
16 const instancedServices = services.all.filter(service => service.recipe.constructor === this.constructor);
17 // send
18 instancedServices.forEach(service => {
19 let updated = false;
20 serviceCache[service.id] = Object.keys(service).reduce((r, key) => {
21 if (!service[key] || Object !== service[key].constructor) {
22 updated = updated || serviceCache[key] !== service[key];
23 r[key] = service[key];
24 }
25 return r;
26 }, serviceCache[service.id] || {});
27 if (updated) {
28 service.webview.send('-service-update', service);
29 }
30 });
31 }, 1000);
32 return _temp = super(...args), this.events = {
33 }, _temp;
34 }
35
36 async validateUrl(url) {
37 try {
38 const res = await window.fetch(`${url}/api/v1/instance/`, {
39 method: 'GET',
40 headers: {
41 'Content-Type': 'application/json',
42 },
43 });
44 const data = await res.json();
45 // check url field in API response
46 return Object.hasOwnProperty.call(data, 'uri');
47 } catch (err) {
48 console.error(err);
49 }
50 return false;
51 }
52
53};