diff options
author | Markus Hatvan <markus_hatvan@aon.at> | 2021-12-02 23:57:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-03 04:27:13 +0530 |
commit | f64f1b3bd9bec4036748b98ff8ac0f0431749f30 (patch) | |
tree | 33691b4b02a546a7a1665ca29b18e3baa135c9ef /src | |
parent | 5.6.4-nightly.22 [skip ci] (diff) | |
download | ferdium-app-f64f1b3bd9bec4036748b98ff8ac0f0431749f30.tar.gz ferdium-app-f64f1b3bd9bec4036748b98ff8ac0f0431749f30.tar.zst ferdium-app-f64f1b3bd9bec4036748b98ff8ac0f0431749f30.zip |
chore: upgrade commitlint and eslint-plugin-unicorn to latest (#2295)
- upgrade commitlint and eslint-plugin-unicorn dependencies
- update prepare-code script to run lint:fix instead of lint
- fix unicorn/no-await-expression-member lint issues
- various whitespace formatting fixes due to lint:fix
Diffstat (limited to 'src')
-rw-r--r-- | src/components/services/tabs/TabItem.js | 2 | ||||
-rw-r--r-- | src/components/settings/recipes/RecipesDashboard.js | 3 | ||||
-rw-r--r-- | src/containers/settings/EditSettingsScreen.js | 4 | ||||
-rw-r--r-- | src/internal-server/app/Controllers/Http/RecipeController.js | 25 | ||||
-rw-r--r-- | src/internal-server/app/Controllers/Http/ServiceController.js | 32 | ||||
-rw-r--r-- | src/internal-server/app/Controllers/Http/UserController.js | 7 | ||||
-rw-r--r-- | src/internal-server/app/Controllers/Http/WorkspaceController.js | 13 | ||||
-rw-r--r-- | src/lib/Menu.js | 11 | ||||
-rw-r--r-- | src/lib/Tray.js | 11 |
9 files changed, 69 insertions, 39 deletions
diff --git a/src/components/services/tabs/TabItem.js b/src/components/services/tabs/TabItem.js index 5381d7c2b..14be37153 100644 --- a/src/components/services/tabs/TabItem.js +++ b/src/components/services/tabs/TabItem.js | |||
@@ -276,7 +276,7 @@ class TabItem extends Component { | |||
276 | service.isEnabled ? messages.disableService : messages.enableService, | 276 | service.isEnabled ? messages.disableService : messages.enableService, |
277 | ), | 277 | ), |
278 | click: () => (service.isEnabled ? disableService() : enableService()), | 278 | click: () => (service.isEnabled ? disableService() : enableService()), |
279 | accelerator: `${cmdOrCtrlShortcutKey()}+${shiftKey()}+S`, | 279 | accelerator: `${cmdOrCtrlShortcutKey()}+${shiftKey()}+S`, |
280 | }, | 280 | }, |
281 | { | 281 | { |
282 | label: intl.formatMessage( | 282 | label: intl.formatMessage( |
diff --git a/src/components/settings/recipes/RecipesDashboard.js b/src/components/settings/recipes/RecipesDashboard.js index b865bce73..7ec285431 100644 --- a/src/components/settings/recipes/RecipesDashboard.js +++ b/src/components/settings/recipes/RecipesDashboard.js | |||
@@ -51,7 +51,8 @@ const messages = defineMessages({ | |||
51 | }, | 51 | }, |
52 | customRecipeIntro: { | 52 | customRecipeIntro: { |
53 | id: 'settings.recipes.customService.intro', | 53 | id: 'settings.recipes.customService.intro', |
54 | defaultMessage: 'To add a custom service, copy the service recipe folder inside:', | 54 | defaultMessage: |
55 | 'To add a custom service, copy the service recipe folder inside:', | ||
55 | }, | 56 | }, |
56 | openFolder: { | 57 | openFolder: { |
57 | id: 'settings.recipes.customService.openFolder', | 58 | id: 'settings.recipes.customService.openFolder', |
diff --git a/src/containers/settings/EditSettingsScreen.js b/src/containers/settings/EditSettingsScreen.js index 719c71561..720f2c8a1 100644 --- a/src/containers/settings/EditSettingsScreen.js +++ b/src/containers/settings/EditSettingsScreen.js | |||
@@ -621,7 +621,9 @@ class EditSettingsScreen extends Component { | |||
621 | default: DEFAULT_APP_SETTINGS.splitMode, | 621 | default: DEFAULT_APP_SETTINGS.splitMode, |
622 | }, | 622 | }, |
623 | splitColumns: { | 623 | splitColumns: { |
624 | label: `${intl.formatMessage(messages.splitColumns)} (${SPLIT_COLUMNS_MIN}-${SPLIT_COLUMNS_MAX})`, | 624 | label: `${intl.formatMessage( |
625 | messages.splitColumns, | ||
626 | )} (${SPLIT_COLUMNS_MIN}-${SPLIT_COLUMNS_MAX})`, | ||
625 | value: settings.all.app.splitColumns, | 627 | value: settings.all.app.splitColumns, |
626 | default: DEFAULT_APP_SETTINGS.splitColumns, | 628 | default: DEFAULT_APP_SETTINGS.splitColumns, |
627 | }, | 629 | }, |
diff --git a/src/internal-server/app/Controllers/Http/RecipeController.js b/src/internal-server/app/Controllers/Http/RecipeController.js index 1b0ac7035..7e35e6831 100644 --- a/src/internal-server/app/Controllers/Http/RecipeController.js +++ b/src/internal-server/app/Controllers/Http/RecipeController.js | |||
@@ -13,8 +13,10 @@ const RECIPES_URL = `${LIVE_FERDI_API}/${API_VERSION}/recipes`; | |||
13 | class RecipeController { | 13 | class RecipeController { |
14 | // List official and custom recipes | 14 | // List official and custom recipes |
15 | async list({ response }) { | 15 | async list({ response }) { |
16 | const officialRecipes = JSON.parse(await (await fetch(RECIPES_URL)).text()); | 16 | const recipesUrlFetch = await fetch(RECIPES_URL); |
17 | const customRecipesArray = (await Recipe.all()).rows; | 17 | const officialRecipes = JSON.parse(await recipesUrlFetch).text(); |
18 | const allRecipes = await Recipe.all(); | ||
19 | const customRecipesArray = allRecipes.rows; | ||
18 | const customRecipes = customRecipesArray.map(recipe => ({ | 20 | const customRecipes = customRecipesArray.map(recipe => ({ |
19 | id: recipe.recipeId, | 21 | id: recipe.recipeId, |
20 | name: recipe.name, | 22 | name: recipe.name, |
@@ -46,7 +48,8 @@ class RecipeController { | |||
46 | let results; | 48 | let results; |
47 | 49 | ||
48 | if (needle === 'ferdi:custom') { | 50 | if (needle === 'ferdi:custom') { |
49 | const dbResults = (await Recipe.all()).toJSON(); | 51 | const allRecipes = await Recipe.all(); |
52 | const dbResults = allRecipes.toJSON(); | ||
50 | results = dbResults.map(recipe => ({ | 53 | results = dbResults.map(recipe => ({ |
51 | id: recipe.recipeId, | 54 | id: recipe.recipeId, |
52 | name: recipe.name, | 55 | name: recipe.name, |
@@ -56,20 +59,18 @@ class RecipeController { | |||
56 | let remoteResults = []; | 59 | let remoteResults = []; |
57 | // eslint-disable-next-line eqeqeq | 60 | // eslint-disable-next-line eqeqeq |
58 | if (Env.get('CONNECT_WITH_FRANZ') == 'true') { | 61 | if (Env.get('CONNECT_WITH_FRANZ') == 'true') { |
59 | remoteResults = JSON.parse( | 62 | const recipesUrlFetch = await fetch( |
60 | await ( | 63 | `${RECIPES_URL}/search?needle=${encodeURIComponent(needle)}`, |
61 | await fetch( | ||
62 | `${RECIPES_URL}/search?needle=${encodeURIComponent(needle)}`, | ||
63 | ) | ||
64 | ).text(), | ||
65 | ); | 64 | ); |
65 | remoteResults = JSON.parse(await recipesUrlFetch.text()); | ||
66 | } | 66 | } |
67 | 67 | ||
68 | debug('remoteResults:', remoteResults); | 68 | debug('remoteResults:', remoteResults); |
69 | 69 | ||
70 | const localResultsArray = ( | 70 | const recipeQuery = await Recipe.query() |
71 | await Recipe.query().where('name', 'LIKE', `%${needle}%`).fetch() | 71 | .where('name', 'LIKE', `%${needle}%`) |
72 | ).toJSON(); | 72 | .fetch(); |
73 | const localResultsArray = recipeQuery.toJSON(); | ||
73 | const localResults = localResultsArray.map(recipe => ({ | 74 | const localResults = localResultsArray.map(recipe => ({ |
74 | id: recipe.recipeId, | 75 | id: recipe.recipeId, |
75 | name: recipe.name, | 76 | name: recipe.name, |
diff --git a/src/internal-server/app/Controllers/Http/ServiceController.js b/src/internal-server/app/Controllers/Http/ServiceController.js index c4ca5a113..a3add4464 100644 --- a/src/internal-server/app/Controllers/Http/ServiceController.js +++ b/src/internal-server/app/Controllers/Http/ServiceController.js | |||
@@ -34,6 +34,7 @@ class ServiceController { | |||
34 | do { | 34 | do { |
35 | serviceId = uuid(); | 35 | serviceId = uuid(); |
36 | } while ( | 36 | } while ( |
37 | // eslint-disable-next-line no-await-in-loop, unicorn/no-await-expression-member | ||
37 | (await Service.query().where('serviceId', serviceId).fetch()).rows | 38 | (await Service.query().where('serviceId', serviceId).fetch()).rows |
38 | .length > 0 | 39 | .length > 0 |
39 | ); | 40 | ); |
@@ -68,7 +69,8 @@ class ServiceController { | |||
68 | 69 | ||
69 | // List all services a user has created | 70 | // List all services a user has created |
70 | async list({ response }) { | 71 | async list({ response }) { |
71 | const services = (await Service.all()).rows; | 72 | const allServices = await Service.all(); |
73 | const services = allServices.rows; | ||
72 | // Convert to array with all data Franz wants | 74 | // Convert to array with all data Franz wants |
73 | const servicesArray = services.map(service => { | 75 | const servicesArray = services.map(service => { |
74 | const settings = | 76 | const settings = |
@@ -111,8 +113,8 @@ class ServiceController { | |||
111 | size: '2mb', | 113 | size: '2mb', |
112 | }); | 114 | }); |
113 | const { id } = params; | 115 | const { id } = params; |
114 | const service = (await Service.query().where('serviceId', id).fetch()) | 116 | const serviceQuery = await Service.query().where('serviceId', id).fetch(); |
115 | .rows[0]; | 117 | const service = serviceQuery.rows[0]; |
116 | const settings = | 118 | const settings = |
117 | typeof service.settings === 'string' | 119 | typeof service.settings === 'string' |
118 | ? JSON.parse(service.settings) | 120 | ? JSON.parse(service.settings) |
@@ -166,8 +168,8 @@ class ServiceController { | |||
166 | const { id } = params; | 168 | const { id } = params; |
167 | 169 | ||
168 | // Get current settings from db | 170 | // Get current settings from db |
169 | const serviceData = (await Service.query().where('serviceId', id).fetch()) | 171 | const serviceQuery = await Service.query().where('serviceId', id).fetch(); |
170 | .rows[0]; | 172 | const serviceData = serviceQuery.rows[0]; |
171 | 173 | ||
172 | const settings = { | 174 | const settings = { |
173 | ...(typeof serviceData.settings === 'string' | 175 | ...(typeof serviceData.settings === 'string' |
@@ -185,8 +187,10 @@ class ServiceController { | |||
185 | }); | 187 | }); |
186 | 188 | ||
187 | // Get updated row | 189 | // Get updated row |
188 | const service = (await Service.query().where('serviceId', id).fetch()) | 190 | const anotherServiceQuery = await Service.query() |
189 | .rows[0]; | 191 | .where('serviceId', id) |
192 | .fetch(); | ||
193 | const service = anotherServiceQuery.rows[0]; | ||
190 | 194 | ||
191 | return response.send({ | 195 | return response.send({ |
192 | data: { | 196 | data: { |
@@ -218,11 +222,12 @@ class ServiceController { | |||
218 | 222 | ||
219 | for (const service of Object.keys(data)) { | 223 | for (const service of Object.keys(data)) { |
220 | // Get current settings from db | 224 | // Get current settings from db |
221 | const serviceData = ( | 225 | // eslint-disable-next-line no-await-in-loop |
222 | await Service.query() // eslint-disable-line no-await-in-loop | 226 | const serviceQuery = await Service.query() |
223 | .where('serviceId', service) | 227 | .where('serviceId', service) |
224 | .fetch() | 228 | .fetch(); |
225 | ).rows[0]; | 229 | |
230 | const serviceData = serviceQuery.rows[0]; | ||
226 | 231 | ||
227 | const settings = { | 232 | const settings = { |
228 | ...JSON.parse(serviceData.settings), | 233 | ...JSON.parse(serviceData.settings), |
@@ -238,7 +243,8 @@ class ServiceController { | |||
238 | } | 243 | } |
239 | 244 | ||
240 | // Get new services | 245 | // Get new services |
241 | const services = (await Service.all()).rows; | 246 | const allServices = await Service.all(); |
247 | const services = allServices.rows; | ||
242 | // Convert to array with all data Franz wants | 248 | // Convert to array with all data Franz wants |
243 | const servicesArray = services.map(service => { | 249 | const servicesArray = services.map(service => { |
244 | const settings = | 250 | const settings = |
diff --git a/src/internal-server/app/Controllers/Http/UserController.js b/src/internal-server/app/Controllers/Http/UserController.js index 2ecc8241c..abfbc2470 100644 --- a/src/internal-server/app/Controllers/Http/UserController.js +++ b/src/internal-server/app/Controllers/Http/UserController.js | |||
@@ -1,3 +1,4 @@ | |||
1 | /* eslint-disable no-await-in-loop, unicorn/no-await-expression-member */ | ||
1 | const User = use('App/Models/User'); | 2 | const User = use('App/Models/User'); |
2 | const Service = use('App/Models/Service'); | 3 | const Service = use('App/Models/Service'); |
3 | const Workspace = use('App/Models/Workspace'); | 4 | const Workspace = use('App/Models/Workspace'); |
@@ -230,8 +231,10 @@ class UserController { | |||
230 | auth, | 231 | auth, |
231 | response, | 232 | response, |
232 | }) { | 233 | }) { |
233 | const services = (await Service.all()).toJSON(); | 234 | const allServices = await Service.all(); |
234 | const workspaces = (await Workspace.all()).toJSON(); | 235 | const services = allServices.toJSON(); |
236 | const allWorkspaces = await Workspace.all(); | ||
237 | const workspaces = allWorkspaces.toJSON(); | ||
235 | 238 | ||
236 | const exportData = { | 239 | const exportData = { |
237 | username: 'Ferdi', | 240 | username: 'Ferdi', |
diff --git a/src/internal-server/app/Controllers/Http/WorkspaceController.js b/src/internal-server/app/Controllers/Http/WorkspaceController.js index 528721f13..9ba2b174e 100644 --- a/src/internal-server/app/Controllers/Http/WorkspaceController.js +++ b/src/internal-server/app/Controllers/Http/WorkspaceController.js | |||
@@ -25,11 +25,13 @@ class WorkspaceController { | |||
25 | do { | 25 | do { |
26 | workspaceId = uuid(); | 26 | workspaceId = uuid(); |
27 | } while ( | 27 | } while ( |
28 | // eslint-disable-next-line no-await-in-loop, unicorn/no-await-expression-member | ||
28 | (await Workspace.query().where('workspaceId', workspaceId).fetch()).rows | 29 | (await Workspace.query().where('workspaceId', workspaceId).fetch()).rows |
29 | .length > 0 | 30 | .length > 0 |
30 | ); | 31 | ); |
31 | 32 | ||
32 | const order = (await Workspace.all()).rows.length; | 33 | const allWorkspaces = await Workspace.all(); |
34 | const order = allWorkspaces.rows.length; | ||
33 | const { name } = data; | 35 | const { name } = data; |
34 | delete data.name; | 36 | delete data.name; |
35 | 37 | ||
@@ -76,8 +78,10 @@ class WorkspaceController { | |||
76 | }); | 78 | }); |
77 | 79 | ||
78 | // Get updated row | 80 | // Get updated row |
79 | const workspace = (await Workspace.query().where('workspaceId', id).fetch()) | 81 | const workspaceQuery = await Workspace.query() |
80 | .rows[0]; | 82 | .where('workspaceId', id) |
83 | .fetch(); | ||
84 | const workspace = workspaceQuery.rows[0]; | ||
81 | 85 | ||
82 | return response.send({ | 86 | return response.send({ |
83 | id: workspace.workspaceId, | 87 | id: workspace.workspaceId, |
@@ -118,7 +122,8 @@ class WorkspaceController { | |||
118 | 122 | ||
119 | // List all workspaces a user has created | 123 | // List all workspaces a user has created |
120 | async list({ response }) { | 124 | async list({ response }) { |
121 | const workspaces = (await Workspace.all()).rows; | 125 | const allWorkspaces = await Workspace.all(); |
126 | const workspaces = allWorkspaces.rows; | ||
122 | // Convert to array with all data Franz wants | 127 | // Convert to array with all data Franz wants |
123 | let workspacesArray = []; | 128 | let workspacesArray = []; |
124 | if (workspaces) { | 129 | if (workspaces) { |
diff --git a/src/lib/Menu.js b/src/lib/Menu.js index 892b2ff3c..8e529d859 100644 --- a/src/lib/Menu.js +++ b/src/lib/Menu.js | |||
@@ -1,5 +1,11 @@ | |||
1 | import { clipboard } from 'electron'; | 1 | import { clipboard } from 'electron'; |
2 | import { app, Menu, dialog, systemPreferences, getCurrentWindow } from '@electron/remote'; | 2 | import { |
3 | app, | ||
4 | Menu, | ||
5 | dialog, | ||
6 | systemPreferences, | ||
7 | getCurrentWindow, | ||
8 | } from '@electron/remote'; | ||
3 | import { autorun, observable } from 'mobx'; | 9 | import { autorun, observable } from 'mobx'; |
4 | import { defineMessages } from 'react-intl'; | 10 | import { defineMessages } from 'react-intl'; |
5 | import { | 11 | import { |
@@ -950,7 +956,8 @@ class FranzMenu { | |||
950 | click: () => { | 956 | click: () => { |
951 | this.actions.service.setActive({ serviceId: service.id }); | 957 | this.actions.service.setActive({ serviceId: service.id }); |
952 | 958 | ||
953 | if (isMac && i === 0) { // feat(Mac): Open Window with Cmd+1 | 959 | if (isMac && i === 0) { |
960 | // feat(Mac): Open Window with Cmd+1 | ||
954 | getCurrentWindow().restore(); | 961 | getCurrentWindow().restore(); |
955 | } | 962 | } |
956 | }, | 963 | }, |
diff --git a/src/lib/Tray.js b/src/lib/Tray.js index 655dc416f..63382483e 100644 --- a/src/lib/Tray.js +++ b/src/lib/Tray.js | |||
@@ -33,15 +33,20 @@ export default class TrayIcon { | |||
33 | 33 | ||
34 | mainWindow = null; | 34 | mainWindow = null; |
35 | 35 | ||
36 | trayMenuTemplate = (tray) => [ | 36 | trayMenuTemplate = tray => [ |
37 | { | 37 | { |
38 | label: (tray.mainWindow.isVisible() && tray.mainWindow.isFocused()) ? 'Hide Ferdi' : 'Show Ferdi', | 38 | label: |
39 | tray.mainWindow.isVisible() && tray.mainWindow.isFocused() | ||
40 | ? 'Hide Ferdi' | ||
41 | : 'Show Ferdi', | ||
39 | click() { | 42 | click() { |
40 | tray._toggleWindow(); | 43 | tray._toggleWindow(); |
41 | }, | 44 | }, |
42 | }, | 45 | }, |
43 | { | 46 | { |
44 | label: tray.isAppMuted ? 'Enable Notifications && Audio' : 'Disable Notifications && Audio', | 47 | label: tray.isAppMuted |
48 | ? 'Enable Notifications && Audio' | ||
49 | : 'Disable Notifications && Audio', | ||
45 | click() { | 50 | click() { |
46 | if (!tray.mainWindow) return; | 51 | if (!tray.mainWindow) return; |
47 | tray.mainWindow.webContents.send('muteApp'); | 52 | tray.mainWindow.webContents.send('muteApp'); |