aboutsummaryrefslogtreecommitdiffstats
path: root/src/features
diff options
context:
space:
mode:
Diffstat (limited to 'src/features')
-rw-r--r--src/features/appearance/index.js26
-rw-r--r--src/features/communityRecipes/store.js8
-rw-r--r--src/features/quickSwitch/Component.js6
-rw-r--r--src/features/serviceProxy/index.js4
-rwxr-xr-xsrc/features/settingsWS/store.js20
-rw-r--r--src/features/todos/preload.js12
-rw-r--r--src/features/utils/FeatureStore.js8
-rw-r--r--src/features/webControls/containers/WebControlsScreen.js28
-rw-r--r--src/features/workspaces/components/EditWorkspaceForm.js2
-rw-r--r--src/features/workspaces/components/WorkspaceDrawerItem.js2
-rw-r--r--src/features/workspaces/models/Workspace.js2
-rw-r--r--src/features/workspaces/store.js8
12 files changed, 69 insertions, 57 deletions
diff --git a/src/features/appearance/index.js b/src/features/appearance/index.js
index d1db68ac6..0c935be32 100644
--- a/src/features/appearance/index.js
+++ b/src/features/appearance/index.js
@@ -14,7 +14,7 @@ function createStyleElement() {
14} 14}
15 15
16function setAppearance(style) { 16function setAppearance(style) {
17 const styleElement = document.getElementById(STYLE_ELEMENT_ID); 17 const styleElement = document.querySelector(`#${STYLE_ELEMENT_ID}`);
18 18
19 if (styleElement) { 19 if (styleElement) {
20 styleElement.innerHTML = style; 20 styleElement.innerHTML = style;
@@ -30,18 +30,18 @@ function darkenAbsolute(originalColor, absoluteChange) {
30function generateAccentStyle(accentColorStr) { 30function generateAccentStyle(accentColorStr) {
31 let style = ''; 31 let style = '';
32 32
33 Object.keys(themeInfo).forEach(property => { 33 for (const property of Object.keys(themeInfo)) {
34 style += ` 34 style += `
35 ${themeInfo[property]} { 35 ${themeInfo[property]} {
36 ${property}: ${accentColorStr}; 36 ${property}: ${accentColorStr};
37 } 37 }
38 `; 38 `;
39 }); 39 }
40 40
41 let accentColor = color(DEFAULT_APP_SETTINGS.accentColor); 41 let accentColor = color(DEFAULT_APP_SETTINGS.accentColor);
42 try { 42 try {
43 accentColor = color(accentColorStr); 43 accentColor = color(accentColorStr);
44 } catch (e) { 44 } catch {
45 // Ignore invalid accent color. 45 // Ignore invalid accent color.
46 } 46 }
47 const darkerColorStr = darkenAbsolute(accentColor, 5).hex(); 47 const darkerColorStr = darkenAbsolute(accentColor, 5).hex();
@@ -133,14 +133,14 @@ function generateShowDragAreaStyle(accentColor) {
133} 133}
134 134
135function generateVerticalStyle(widthStr, alwaysShowWorkspaces) { 135function generateVerticalStyle(widthStr, alwaysShowWorkspaces) {
136 if (!document.getElementById('vertical-style')) { 136 if (!document.querySelector('#vertical-style')) {
137 const link = document.createElement('link'); 137 const link = document.createElement('link');
138 link.id = 'vertical-style'; 138 link.id = 'vertical-style';
139 link.rel = 'stylesheet'; 139 link.rel = 'stylesheet';
140 link.type = 'text/css'; 140 link.type = 'text/css';
141 link.href = './styles/vertical.css'; 141 link.href = './styles/vertical.css';
142 142
143 document.head.appendChild(link); 143 document.head.append(link);
144 } 144 }
145 const width = Number(widthStr); 145 const width = Number(widthStr);
146 const sidebarWidth = width - 4; 146 const sidebarWidth = width - 4;
@@ -150,12 +150,12 @@ function generateVerticalStyle(widthStr, alwaysShowWorkspaces) {
150 .sidebar { 150 .sidebar {
151 height: ${sidebarWidth + verticalStyleOffset + 1}px !important; 151 height: ${sidebarWidth + verticalStyleOffset + 1}px !important;
152 ${ 152 ${
153 alwaysShowWorkspaces 153 alwaysShowWorkspaces
154 ? ` 154 ? `
155 width: calc(100% - 300px) !important; 155 width: calc(100% - 300px) !important;
156 ` 156 `
157 : '' 157 : ''
158} 158 }
159 } 159 }
160 160
161 .sidebar .sidebar__button { 161 .sidebar .sidebar__button {
@@ -220,10 +220,10 @@ function generateStyle(settings) {
220 } 220 }
221 if (useVerticalStyle) { 221 if (useVerticalStyle) {
222 style += generateVerticalStyle(serviceRibbonWidth, alwaysShowWorkspaces); 222 style += generateVerticalStyle(serviceRibbonWidth, alwaysShowWorkspaces);
223 } else if (document.getElementById('vertical-style')) { 223 } else if (document.querySelector('#vertical-style')) {
224 const link = document.getElementById('vertical-style'); 224 const link = document.querySelector('#vertical-style');
225 if (link) { 225 if (link) {
226 document.head.removeChild(link); 226 link.remove();
227 } 227 }
228 } 228 }
229 if (alwaysShowWorkspaces) { 229 if (alwaysShowWorkspaces) {
diff --git a/src/features/communityRecipes/store.js b/src/features/communityRecipes/store.js
index a3614dd11..05e18e2f7 100644
--- a/src/features/communityRecipes/store.js
+++ b/src/features/communityRecipes/store.js
@@ -18,11 +18,13 @@ export class CommunityRecipesStore extends FeatureStore {
18 @computed get communityRecipes() { 18 @computed get communityRecipes() {
19 if (!this.stores) return []; 19 if (!this.stores) return [];
20 20
21 return this.stores.recipePreviews.dev.map((r) => { 21 return this.stores.recipePreviews.dev.map(recipePreview => {
22 // TODO: Need to figure out if this is even necessary/used 22 // TODO: Need to figure out if this is even necessary/used
23 r.isDevRecipe = !!r.author.find((a) => a.email === this.stores.user.data.email); 23 recipePreview.isDevRecipe = !!recipePreview.author.some(
24 author => author.email === this.stores.user.data.email,
25 );
24 26
25 return r; 27 return recipePreview;
26 }); 28 });
27 } 29 }
28} 30}
diff --git a/src/features/quickSwitch/Component.js b/src/features/quickSwitch/Component.js
index df2bf968d..f21db0ebd 100644
--- a/src/features/quickSwitch/Component.js
+++ b/src/features/quickSwitch/Component.js
@@ -140,7 +140,7 @@ class QuickSwitchModal extends Component {
140 let services = []; 140 let services = [];
141 if ( 141 if (
142 this.state.search && 142 this.state.search &&
143 compact(invoke(this.state.search, 'match', /^[a-z0-9]/i)).length > 0 143 compact(invoke(this.state.search, 'match', /^[\da-z]/i)).length > 0
144 ) { 144 ) {
145 // Apply simple search algorythm to list of all services 145 // Apply simple search algorythm to list of all services
146 services = this.props.stores.services.allDisplayed; 146 services = this.props.stores.services.allDisplayed;
@@ -261,7 +261,7 @@ class QuickSwitchModal extends Component {
261 // Wrapped inside timeout to let the modal render first 261 // Wrapped inside timeout to let the modal render first
262 setTimeout(() => { 262 setTimeout(() => {
263 if (this.inputRef.current) { 263 if (this.inputRef.current) {
264 this.inputRef.current.getElementsByTagName('input')[0].focus(); 264 this.inputRef.current.querySelectorAll('input')[0].focus();
265 } 265 }
266 }, 10); 266 }, 10);
267 267
@@ -273,7 +273,7 @@ class QuickSwitchModal extends Component {
273 // search query change when modal not visible 273 // search query change when modal not visible
274 setTimeout(() => { 274 setTimeout(() => {
275 if (this.inputRef.current) { 275 if (this.inputRef.current) {
276 this.inputRef.current.getElementsByTagName('input')[0].blur(); 276 this.inputRef.current.querySelectorAll('input')[0].blur();
277 } 277 }
278 }, 100); 278 }, 100);
279 279
diff --git a/src/features/serviceProxy/index.js b/src/features/serviceProxy/index.js
index eb7116651..b9320cda9 100644
--- a/src/features/serviceProxy/index.js
+++ b/src/features/serviceProxy/index.js
@@ -18,7 +18,7 @@ export default function init(stores) {
18 18
19 debug('Service Proxy autorun'); 19 debug('Service Proxy autorun');
20 20
21 services.forEach((service) => { 21 for (const service of services) {
22 const s = session.fromPartition(`persist:service-${service.id}`); 22 const s = session.fromPartition(`persist:service-${service.id}`);
23 23
24 if (config.isEnabled) { 24 if (config.isEnabled) {
@@ -33,6 +33,6 @@ export default function init(stores) {
33 }); 33 });
34 } 34 }
35 } 35 }
36 }); 36 }
37 }); 37 });
38} 38}
diff --git a/src/features/settingsWS/store.js b/src/features/settingsWS/store.js
index 9100f33d1..e36ccee72 100755
--- a/src/features/settingsWS/store.js
+++ b/src/features/settingsWS/store.js
@@ -25,11 +25,13 @@ export class SettingsWSStore extends FeatureStore {
25 this.stores = stores; 25 this.stores = stores;
26 this.actions = actions; 26 this.actions = actions;
27 27
28 this._registerReactions(createReactions([ 28 this._registerReactions(
29 this._initialize.bind(this), 29 createReactions([
30 this._reconnect.bind(this), 30 this._initialize.bind(this),
31 this._close.bind(this), 31 this._reconnect.bind(this),
32 ])); 32 this._close.bind(this),
33 ]),
34 );
33 } 35 }
34 36
35 connect() { 37 connect() {
@@ -51,12 +53,12 @@ export class SettingsWSStore extends FeatureStore {
51 this.heartbeat(); 53 this.heartbeat();
52 }); 54 });
53 55
54 this.ws.on('message', (data) => { 56 this.ws.on('message', data => {
55 const resp = JSON.parse(data); 57 const resp = JSON.parse(data);
56 debug('Received message', resp); 58 debug('Received message', resp);
57 59
58 if (resp.id) { 60 if (resp.id) {
59 this.stores.user.getUserInfoRequest.patch((result) => { 61 this.stores.user.getUserInfoRequest.patch(result => {
60 if (!result) return; 62 if (!result) return;
61 63
62 debug('Patching user object with new values'); 64 debug('Patching user object with new values');
@@ -66,8 +68,8 @@ export class SettingsWSStore extends FeatureStore {
66 }); 68 });
67 69
68 this.ws.on('ping', this.heartbeat.bind(this)); 70 this.ws.on('ping', this.heartbeat.bind(this));
69 } catch (err) { 71 } catch (error) {
70 console.err(err); 72 console.error(error);
71 } 73 }
72 } 74 }
73 75
diff --git a/src/features/todos/preload.js b/src/features/todos/preload.js
index 9bd76a704..3b86ddbc5 100644
--- a/src/features/todos/preload.js
+++ b/src/features/todos/preload.js
@@ -7,7 +7,9 @@ debug('Preloading Todos Webview');
7 7
8let hostMessageListener = ({ action }) => { 8let hostMessageListener = ({ action }) => {
9 switch (action) { 9 switch (action) {
10 case 'todos:initialize-as-service': ipcRenderer.sendToHost('hello'); break; 10 case 'todos:initialize-as-service':
11 ipcRenderer.sendToHost('hello');
12 break;
11 default: 13 default:
12 } 14 }
13}; 15};
@@ -15,7 +17,9 @@ let hostMessageListener = ({ action }) => {
15window.ferdi = { 17window.ferdi = {
16 onInitialize(ipcHostMessageListener) { 18 onInitialize(ipcHostMessageListener) {
17 hostMessageListener = ipcHostMessageListener; 19 hostMessageListener = ipcHostMessageListener;
18 ipcRenderer.sendToHost(IPC.TODOS_CLIENT_CHANNEL, { action: 'todos:initialized' }); 20 ipcRenderer.sendToHost(IPC.TODOS_CLIENT_CHANNEL, {
21 action: 'todos:initialized',
22 });
19 }, 23 },
20 sendToHost(message) { 24 sendToHost(message) {
21 ipcRenderer.sendToHost(IPC.TODOS_CLIENT_CHANNEL, message); 25 ipcRenderer.sendToHost(IPC.TODOS_CLIENT_CHANNEL, message);
@@ -30,7 +34,7 @@ ipcRenderer.on(IPC.TODOS_HOST_CHANNEL, (event, message) => {
30if (window.location.href === 'https://app.franztodos.com/login/') { 34if (window.location.href === 'https://app.franztodos.com/login/') {
31 // Insert info element informing about Franz accounts 35 // Insert info element informing about Franz accounts
32 const infoElement = document.createElement('p'); 36 const infoElement = document.createElement('p');
33 infoElement.innerText = `You are using Franz's official Todo Service. 37 infoElement.textContent = `You are using Franz's official Todo Service.
34This service will only work with accounts registered with Franz - no Ferdi accounts will work here! 38This service will only work with accounts registered with Franz - no Ferdi accounts will work here!
35If you do not have a Franz account you can change the Todo service by going into Ferdi's settings and changing the "Todo server". 39If you do not have a Franz account you can change the Todo service by going into Ferdi's settings and changing the "Todo server".
36You can choose any service as this Todo server, e.g. Todoist or Apple Notes.`; 40You can choose any service as this Todo server, e.g. Todoist or Apple Notes.`;
@@ -42,7 +46,7 @@ You can choose any service as this Todo server, e.g. Todoist or Apple Notes.`;
42 const textElement = document.querySelector('p'); 46 const textElement = document.querySelector('p');
43 if (textElement) { 47 if (textElement) {
44 clearInterval(waitForReact); 48 clearInterval(waitForReact);
45 textElement.parentElement.insertBefore(infoElement, textElement); 49 textElement.parentElement?.insertBefore(infoElement, textElement);
46 } else { 50 } else {
47 numChecks += 1; 51 numChecks += 1;
48 52
diff --git a/src/features/utils/FeatureStore.js b/src/features/utils/FeatureStore.js
index 4d4e217a9..afe726294 100644
--- a/src/features/utils/FeatureStore.js
+++ b/src/features/utils/FeatureStore.js
@@ -16,11 +16,11 @@ export class FeatureStore {
16 } 16 }
17 17
18 _startActions(actions = this._actions) { 18 _startActions(actions = this._actions) {
19 actions.forEach((a) => a.start()); 19 for (const a of actions) a.start();
20 } 20 }
21 21
22 _stopActions(actions = this._actions) { 22 _stopActions(actions = this._actions) {
23 actions.forEach((a) => a.stop()); 23 for (const a of actions) a.stop();
24 } 24 }
25 25
26 // REACTIONS 26 // REACTIONS
@@ -31,10 +31,10 @@ export class FeatureStore {
31 } 31 }
32 32
33 _startReactions(reactions = this._reactions) { 33 _startReactions(reactions = this._reactions) {
34 reactions.forEach((r) => r.start()); 34 for (const r of reactions) r.start();
35 } 35 }
36 36
37 _stopReactions(reactions = this._reactions) { 37 _stopReactions(reactions = this._reactions) {
38 reactions.forEach((r) => r.stop()); 38 for (const r of reactions) r.stop();
39 } 39 }
40} 40}
diff --git a/src/features/webControls/containers/WebControlsScreen.js b/src/features/webControls/containers/WebControlsScreen.js
index e1e1b9991..0273bb13e 100644
--- a/src/features/webControls/containers/WebControlsScreen.js
+++ b/src/features/webControls/containers/WebControlsScreen.js
@@ -16,7 +16,8 @@ const URL_EVENTS = [
16 'did-navigate-in-page', 16 'did-navigate-in-page',
17]; 17];
18 18
19@inject('stores', 'actions') @observer 19@inject('stores', 'actions')
20@observer
20class WebControlsScreen extends Component { 21class WebControlsScreen extends Component {
21 @observable url = ''; 22 @observable url = '';
22 23
@@ -36,15 +37,15 @@ class WebControlsScreen extends Component {
36 this.webview = service.webview; 37 this.webview = service.webview;
37 this.url = this.webview.getURL(); 38 this.url = this.webview.getURL();
38 39
39 URL_EVENTS.forEach((event) => { 40 for (const event of URL_EVENTS) {
40 this.webview.addEventListener(event, (e) => { 41 this.webview.addEventListener(event, e => {
41 if (!e.isMainFrame) return; 42 if (!e.isMainFrame) return;
42 43
43 this.url = e.url; 44 this.url = e.url;
44 this.canGoBack = this.webview.canGoBack(); 45 this.canGoBack = this.webview.canGoBack();
45 this.canGoForward = this.webview.canGoForward(); 46 this.canGoForward = this.webview.canGoForward();
46 }); 47 });
47 }); 48 }
48 } 49 }
49 }); 50 });
50 } 51 }
@@ -83,13 +84,16 @@ class WebControlsScreen extends Component {
83 84
84 try { 85 try {
85 url = new URL(url).toString(); 86 url = new URL(url).toString();
86 } catch (err) { 87 } catch {
87 // eslint-disable-next-line no-useless-escape 88 url =
88 if (url.match(/^((?!-))(xn--)?[a-z0-9][a-z0-9-_]{0,61}[a-z0-9]{0,1}\.(xn--)?([a-z0-9\-]{1,61}|[a-z0-9-]{1,30}\.[a-z]{2,})$/)) { 89 // eslint-disable-next-line no-useless-escape
89 url = `http://${url}`; 90 /^((?!-))(xn--)?[\da-z][\d_a-z-]{0,61}[\da-z]{0,1}\.(xn--)?([\da-z\-]{1,61}|[\da-z-]{1,30}\.[a-z]{2,})$/.test(
90 } else { 91 url,
91 url = SEARCH_ENGINE_URLS[this.settings.app.searchEngine]({ searchTerm: url }); 92 )
92 } 93 ? `http://${url}`
94 : SEARCH_ENGINE_URLS[this.settings.app.searchEngine]({
95 searchTerm: url,
96 });
93 } 97 }
94 98
95 this.webview.loadURL(url); 99 this.webview.loadURL(url);
@@ -114,7 +118,7 @@ class WebControlsScreen extends Component {
114 goBack={() => this.goBack()} 118 goBack={() => this.goBack()}
115 canGoForward={this.canGoForward} 119 canGoForward={this.canGoForward}
116 goForward={() => this.goForward()} 120 goForward={() => this.goForward()}
117 navigate={(url) => this.navigate(url)} 121 navigate={url => this.navigate(url)}
118 url={this.url} 122 url={this.url}
119 /> 123 />
120 ); 124 );
diff --git a/src/features/workspaces/components/EditWorkspaceForm.js b/src/features/workspaces/components/EditWorkspaceForm.js
index cae95e9ed..f562733dd 100644
--- a/src/features/workspaces/components/EditWorkspaceForm.js
+++ b/src/features/workspaces/components/EditWorkspaceForm.js
@@ -108,7 +108,7 @@ class EditWorkspaceForm extends Component {
108 default: false, 108 default: false,
109 }, 109 },
110 services: { 110 services: {
111 value: workspace.services.slice(), 111 value: [...workspace.services],
112 }, 112 },
113 }, 113 },
114 }); 114 });
diff --git a/src/features/workspaces/components/WorkspaceDrawerItem.js b/src/features/workspaces/components/WorkspaceDrawerItem.js
index 82e1b81a4..7df2b60be 100644
--- a/src/features/workspaces/components/WorkspaceDrawerItem.js
+++ b/src/features/workspaces/components/WorkspaceDrawerItem.js
@@ -143,7 +143,7 @@ class WorkspaceDrawerItem extends Component {
143 isActive ? classes.activeServices : null, 143 isActive ? classes.activeServices : null,
144 ])} 144 ])}
145 > 145 >
146 {services.length 146 {services.length > 0
147 ? services.join(', ') 147 ? services.join(', ')
148 : intl.formatMessage(messages.noServicesAddedYet)} 148 : intl.formatMessage(messages.noServicesAddedYet)}
149 </span> 149 </span>
diff --git a/src/features/workspaces/models/Workspace.js b/src/features/workspaces/models/Workspace.js
index d9488e991..14add9437 100644
--- a/src/features/workspaces/models/Workspace.js
+++ b/src/features/workspaces/models/Workspace.js
@@ -15,7 +15,7 @@ export default class Workspace {
15 15
16 constructor(data) { 16 constructor(data) {
17 if (!data.id) { 17 if (!data.id) {
18 throw Error('Workspace requires Id'); 18 throw new Error('Workspace requires Id');
19 } 19 }
20 20
21 this.id = data.id; 21 this.id = data.id;
diff --git a/src/features/workspaces/store.js b/src/features/workspaces/store.js
index ec9d7ee7f..73e882990 100644
--- a/src/features/workspaces/store.js
+++ b/src/features/workspaces/store.js
@@ -302,8 +302,8 @@ export default class WorkspacesStore extends FeatureStore {
302 const { allServicesRequest } = services; 302 const { allServicesRequest } = services;
303 const servicesHaveBeenLoaded = allServicesRequest.wasExecuted && !allServicesRequest.isError; 303 const servicesHaveBeenLoaded = allServicesRequest.wasExecuted && !allServicesRequest.isError;
304 // Loop through all workspaces and remove invalid service ids (locally) 304 // Loop through all workspaces and remove invalid service ids (locally)
305 this.workspaces.forEach((workspace) => { 305 for (const workspace of this.workspaces) {
306 workspace.services.forEach((serviceId) => { 306 for (const serviceId of workspace.services) {
307 if ( 307 if (
308 servicesHaveBeenLoaded 308 servicesHaveBeenLoaded
309 && !services.one(serviceId) 309 && !services.one(serviceId)
@@ -311,7 +311,7 @@ export default class WorkspacesStore extends FeatureStore {
311 ) { 311 ) {
312 workspace.services.remove(serviceId); 312 workspace.services.remove(serviceId);
313 } 313 }
314 }); 314 }
315 }); 315 }
316 }; 316 };
317} 317}