diff options
author | 2019-12-20 19:38:40 +0100 | |
---|---|---|
committer | 2019-12-20 19:38:40 +0100 | |
commit | cea06d3a1645be7896659f06088caf9668ce7837 (patch) | |
tree | 333584c7044eb2f585e356057b9c54fec93e3e07 /uncompressed/mastodon/webview.js | |
parent | Fix missing closing bracket (diff) | |
download | ferdium-recipes-cea06d3a1645be7896659f06088caf9668ce7837.tar.gz ferdium-recipes-cea06d3a1645be7896659f06088caf9668ce7837.tar.zst ferdium-recipes-cea06d3a1645be7896659f06088caf9668ce7837.zip |
Remove Mastodon recipe
Diffstat (limited to 'uncompressed/mastodon/webview.js')
-rw-r--r-- | uncompressed/mastodon/webview.js | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/uncompressed/mastodon/webview.js b/uncompressed/mastodon/webview.js deleted file mode 100644 index dcf715e..0000000 --- a/uncompressed/mastodon/webview.js +++ /dev/null | |||
@@ -1,82 +0,0 @@ | |||
1 | //'use strict'; | ||
2 | |||
3 | const { ipcRenderer } = require('electron'); | ||
4 | |||
5 | const BADGE_AUTO_CLEAR_DELAY = 10000; // delay time for badge clear auto | ||
6 | |||
7 | // MONKEY PATCH: | ||
8 | // fix 'Uncaught TypeError: c.addEventListener is not a function' | ||
9 | // from mastdon code | ||
10 | // see https://github.com/tootsuite/mastodon/blob/c1a41181c52216de9ebeecebf418e6d50172139b/app/javascript/mastodon/actions/notifications.js#L60 | ||
11 | if (!Notification.prototype.addEventListener) { | ||
12 | Notification.prototype.addEventListener = function(){}; | ||
13 | } | ||
14 | |||
15 | module.exports = (Franz, service_) => { | ||
16 | |||
17 | let service = service_; | ||
18 | |||
19 | // save service instance identify | ||
20 | const serviceId = service.id; | ||
21 | |||
22 | // check if this service is active | ||
23 | let activeUpdated = false; | ||
24 | let isActive = service.isActive; | ||
25 | |||
26 | ipcRenderer.on('-service-update', (sender, serviceNew) => { | ||
27 | service = serviceNew; | ||
28 | !activeUpdated && (activeUpdated = isActive != service.isActive); | ||
29 | isActive = service.isActive; | ||
30 | }); | ||
31 | |||
32 | //ipcRenderer.on('settings-update', (sender, settings) => { | ||
33 | // const nextIsActive = serviceId == settings.activeService; | ||
34 | // !activeUpdated && (activeUpdated = isActive != nextIsActive); | ||
35 | // isActive = nextIsActive; | ||
36 | //}); | ||
37 | |||
38 | let replyCount = 0; | ||
39 | let limitBadgeClear = false; | ||
40 | |||
41 | const getMessages = function getMessages() { | ||
42 | const activeUpdated_ = activeUpdated; activeUpdated = false; | ||
43 | |||
44 | // check and redirect to signin page when not loggdin | ||
45 | if (window.location && /\/about$/.test(window.location.pathname)) { | ||
46 | const hasSigninLink = !!document.querySelector('[href$="/auth/sign_in"]'); | ||
47 | if (hasSigninLink) { | ||
48 | window.location.pathname = '/auth/sign_in'; | ||
49 | return; | ||
50 | } | ||
51 | } | ||
52 | |||
53 | // clear replay badge when ... | ||
54 | if (replyCount) { | ||
55 | // this service actived | ||
56 | if (activeUpdated_ && isActive) { | ||
57 | replyCount = 0; | ||
58 | } | ||
59 | // timeout | ||
60 | if (!isActive && limitBadgeClear) { | ||
61 | limitBadgeClear = false; | ||
62 | } | ||
63 | if (isActive && false !== limitBadgeClear && limitBadgeClear <= Date.now()) { | ||
64 | replyCount = 0; | ||
65 | limitBadgeClear = false; | ||
66 | } | ||
67 | } | ||
68 | |||
69 | Franz.setBadge(replyCount); | ||
70 | }; | ||
71 | |||
72 | Franz.loop(getMessages); | ||
73 | |||
74 | Franz.onNotify(notification => { | ||
75 | // increment reply count for badge | ||
76 | ++replyCount; | ||
77 | limitBadgeClear = Date.now() + BADGE_AUTO_CLEAR_DELAY; | ||
78 | // | ||
79 | return notification; | ||
80 | |||
81 | }); | ||
82 | }; \ No newline at end of file | ||