diff options
author | 2021-08-08 00:01:37 +0000 | |
---|---|---|
committer | 2021-08-08 05:31:37 +0530 | |
commit | 97d51a7763b14c92ee71ff9a012311dd9498d803 (patch) | |
tree | bd36005031ecb1148f27aa541e7a92a5e3aa4c0c /src/containers/settings/RecipesScreen.js | |
parent | 5.6.1-nightly.17 [skip ci] (diff) | |
download | ferdium-app-97d51a7763b14c92ee71ff9a012311dd9498d803.tar.gz ferdium-app-97d51a7763b14c92ee71ff9a012311dd9498d803.tar.zst ferdium-app-97d51a7763b14c92ee71ff9a012311dd9498d803.zip |
refactor: path-references refactoring and using 'import' instead of 'require' (#1752)
* refactor references to 'userData' and 'appData' directories to move hardcoding into single location
* convert to es6 for lower memory usage as per https://codesource.io/the-difference-between-import-and-require-in-javascript/
Diffstat (limited to 'src/containers/settings/RecipesScreen.js')
-rw-r--r-- | src/containers/settings/RecipesScreen.js | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/containers/settings/RecipesScreen.js b/src/containers/settings/RecipesScreen.js index 93503fb0e..ff3c688fa 100644 --- a/src/containers/settings/RecipesScreen.js +++ b/src/containers/settings/RecipesScreen.js | |||
@@ -1,11 +1,9 @@ | |||
1 | import { shell } from 'electron'; | 1 | import { shell } from 'electron'; |
2 | import { app } from '@electron/remote'; | 2 | import { ensureDirSync, readJsonSync } from 'fs-extra'; |
3 | import fs from 'fs-extra'; | ||
4 | import React, { Component } from 'react'; | 3 | import React, { Component } from 'react'; |
5 | import PropTypes from 'prop-types'; | 4 | import PropTypes from 'prop-types'; |
6 | import { autorun } from 'mobx'; | 5 | import { autorun } from 'mobx'; |
7 | import { inject, observer } from 'mobx-react'; | 6 | import { inject, observer } from 'mobx-react'; |
8 | import path from 'path'; | ||
9 | 7 | ||
10 | import RecipePreviewsStore from '../../stores/RecipePreviewsStore'; | 8 | import RecipePreviewsStore from '../../stores/RecipePreviewsStore'; |
11 | import RecipeStore from '../../stores/RecipesStore'; | 9 | import RecipeStore from '../../stores/RecipesStore'; |
@@ -15,7 +13,7 @@ import UserStore from '../../stores/UserStore'; | |||
15 | import RecipesDashboard from '../../components/settings/recipes/RecipesDashboard'; | 13 | import RecipesDashboard from '../../components/settings/recipes/RecipesDashboard'; |
16 | import ErrorBoundary from '../../components/util/ErrorBoundary'; | 14 | import ErrorBoundary from '../../components/util/ErrorBoundary'; |
17 | import { CUSTOM_WEBSITE_RECIPE_ID, FRANZ_DEV_DOCS } from '../../config'; | 15 | import { CUSTOM_WEBSITE_RECIPE_ID, FRANZ_DEV_DOCS } from '../../config'; |
18 | import { RECIPES_PATH } from '../../environment'; | 16 | import { asarRecipesPath, userDataRecipesPath } from '../../environment'; |
19 | import { communityRecipesStore } from '../../features/communityRecipes'; | 17 | import { communityRecipesStore } from '../../features/communityRecipes'; |
20 | import RecipePreview from '../../models/RecipePreview'; | 18 | import RecipePreview from '../../models/RecipePreview'; |
21 | import AppStore from '../../stores/AppStore'; | 19 | import AppStore from '../../stores/AppStore'; |
@@ -45,7 +43,7 @@ export default @inject('stores', 'actions') @observer class RecipesScreen extend | |||
45 | constructor(props) { | 43 | constructor(props) { |
46 | super(props); | 44 | super(props); |
47 | 45 | ||
48 | this.customRecipes = fs.readJsonSync(path.join(RECIPES_PATH, 'all.json')); | 46 | this.customRecipes = readJsonSync(asarRecipesPath('all.json')); |
49 | } | 47 | } |
50 | 48 | ||
51 | componentDidMount() { | 49 | componentDidMount() { |
@@ -140,7 +138,7 @@ export default @inject('stores', 'actions') @observer class RecipesScreen extend | |||
140 | || recipes.installRecipeRequest.isExecuting | 138 | || recipes.installRecipeRequest.isExecuting |
141 | || recipePreviews.searchRecipePreviewsRequest.isExecuting; | 139 | || recipePreviews.searchRecipePreviewsRequest.isExecuting; |
142 | 140 | ||
143 | const recipeDirectory = path.join(app.getPath('userData'), 'recipes', 'dev'); | 141 | const recipeDirectory = userDataRecipesPath('dev'); |
144 | 142 | ||
145 | return ( | 143 | return ( |
146 | <ErrorBoundary> | 144 | <ErrorBoundary> |
@@ -157,7 +155,7 @@ export default @inject('stores', 'actions') @observer class RecipesScreen extend | |||
157 | recipeFilter={filter} | 155 | recipeFilter={filter} |
158 | recipeDirectory={recipeDirectory} | 156 | recipeDirectory={recipeDirectory} |
159 | openRecipeDirectory={async () => { | 157 | openRecipeDirectory={async () => { |
160 | await fs.ensureDir(recipeDirectory); | 158 | ensureDirSync(recipeDirectory); |
161 | shell.openExternal(`file://${recipeDirectory}`); | 159 | shell.openExternal(`file://${recipeDirectory}`); |
162 | }} | 160 | }} |
163 | openDevDocs={() => { | 161 | openDevDocs={() => { |