diff options
author | 2021-10-05 16:46:55 +0200 | |
---|---|---|
committer | 2021-10-05 16:46:55 +0200 | |
commit | 2484c63d77e05fff384cc08b6ea46a29a22a62ec (patch) | |
tree | 21b8b74f1788407a4cfb13052160398f13424ac6 /recipes/pleroma/webview.js | |
parent | Add check to ensure that generated file 'user.js' is not present in default p... (diff) | |
download | ferdium-recipes-2484c63d77e05fff384cc08b6ea46a29a22a62ec.tar.gz ferdium-recipes-2484c63d77e05fff384cc08b6ea46a29a22a62ec.tar.zst ferdium-recipes-2484c63d77e05fff384cc08b6ea46a29a22a62ec.zip |
chore: repo maintenance (#732)
Diffstat (limited to 'recipes/pleroma/webview.js')
-rw-r--r-- | recipes/pleroma/webview.js | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/recipes/pleroma/webview.js b/recipes/pleroma/webview.js index da76955..2ba184e 100644 --- a/recipes/pleroma/webview.js +++ b/recipes/pleroma/webview.js | |||
@@ -1,6 +1,6 @@ | |||
1 | const titleRegex = /^\((\d+)\)/; | 1 | const titleRegex = /^\((\d+)\)/; |
2 | 2 | ||
3 | const getJson = async (relativeUri) => { | 3 | const getJson = async relativeUri => { |
4 | const req = await window.fetch(`${window.origin}${relativeUri}`, { | 4 | const req = await window.fetch(`${window.origin}${relativeUri}`, { |
5 | Accept: 'application/json', | 5 | Accept: 'application/json', |
6 | }); | 6 | }); |
@@ -8,10 +8,11 @@ const getJson = async (relativeUri) => { | |||
8 | }; | 8 | }; |
9 | 9 | ||
10 | const getInstanceConfig = async () => { | 10 | const getInstanceConfig = async () => { |
11 | const origin = window.origin; | ||
12 | const staticConfig = await getJson('/static/config.json'); | 11 | const staticConfig = await getJson('/static/config.json'); |
13 | try { | 12 | try { |
14 | const frontendConfig = await getJson('/api/pleroma/frontend_configurations'); | 13 | const frontendConfig = await getJson( |
14 | '/api/pleroma/frontend_configurations', | ||
15 | ); | ||
15 | const pleromaFeConfig = frontendConfig.pleroma_fe || {}; | 16 | const pleromaFeConfig = frontendConfig.pleroma_fe || {}; |
16 | return { ...staticConfig, ...pleromaFeConfig }; | 17 | return { ...staticConfig, ...pleromaFeConfig }; |
17 | } catch (e) { | 18 | } catch (e) { |
@@ -33,8 +34,12 @@ const getInstanceLogo = async () => { | |||
33 | logoMask: config.logoMask, | 34 | logoMask: config.logoMask, |
34 | }); | 35 | }); |
35 | }); | 36 | }); |
36 | img.addEventListener('error', (event) => { | 37 | img.addEventListener('error', event => { |
37 | reject(new Error(`${event.type} error loading ${config.logo}: ${event.message}`)); | 38 | reject( |
39 | new Error( | ||
40 | `${event.type} error loading ${config.logo}: ${event.message}`, | ||
41 | ), | ||
42 | ); | ||
38 | }); | 43 | }); |
39 | img.src = `${origin}${config.logo}`; | 44 | img.src = `${origin}${config.logo}`; |
40 | }); | 45 | }); |
@@ -146,16 +151,19 @@ module.exports = Ferdi => { | |||
146 | Ferdi.setBadge(directCount); | 151 | Ferdi.setBadge(directCount); |
147 | }; | 152 | }; |
148 | 153 | ||
149 | getInstanceLogo().then(({ logo, logoMask }) => { | 154 | getInstanceLogo().then( |
150 | const updater = new LogoUpdater(logo, logoMask); | 155 | ({ logo, logoMask }) => { |
151 | Ferdi.loop(() => { | 156 | const updater = new LogoUpdater(logo, logoMask); |
152 | getMessages(); | 157 | Ferdi.loop(() => { |
153 | if (updater.update()) { | 158 | getMessages(); |
154 | Ferdi.setAvatarImage(updater.toDataURL()); | 159 | if (updater.update()) { |
155 | } | 160 | Ferdi.setAvatarImage(updater.toDataURL()); |
156 | }); | 161 | } |
157 | }, (e) => { | 162 | }); |
158 | console.log('Failed to load instance logo', e); | 163 | }, |
159 | Ferdi.loop(getMessages); | 164 | e => { |
160 | }); | 165 | console.log('Failed to load instance logo', e); |
166 | Ferdi.loop(getMessages); | ||
167 | }, | ||
168 | ); | ||
161 | }; | 169 | }; |