diff options
author | André Oliveira <37463445+SpecialAro@users.noreply.github.com> | 2024-05-04 06:21:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-04 10:51:46 +0530 |
commit | 3274625fa309362073a7808490e5d0a3e34b2df6 (patch) | |
tree | a0b82ba9507eed6945d076b27f3e48aeea8aeb55 /src | |
parent | 6.7.4-nightly.3 [skip ci] (diff) | |
download | ferdium-app-3274625fa309362073a7808490e5d0a3e34b2df6.tar.gz ferdium-app-3274625fa309362073a7808490e5d0a3e34b2df6.tar.zst ferdium-app-3274625fa309362073a7808490e5d0a3e34b2df6.zip |
chore: change icons to reduce bundle (#1740)
* Made the sleep in millis more explicit
Diffstat (limited to 'src')
-rw-r--r-- | src/api/server/ServerApi.ts | 14 | ||||
-rw-r--r-- | src/containers/auth/SetupAssistantScreen.tsx | 5 | ||||
-rw-r--r-- | src/models/Recipe.ts | 5 | ||||
-rw-r--r-- | src/models/Service.ts | 4 |
4 files changed, 23 insertions, 5 deletions
diff --git a/src/api/server/ServerApi.ts b/src/api/server/ServerApi.ts index b5dd499ab..5434880dc 100644 --- a/src/api/server/ServerApi.ts +++ b/src/api/server/ServerApi.ts | |||
@@ -12,6 +12,7 @@ import { | |||
12 | statSync, | 12 | statSync, |
13 | writeFileSync, | 13 | writeFileSync, |
14 | } from 'fs-extra'; | 14 | } from 'fs-extra'; |
15 | import ms from 'ms'; | ||
15 | import tar from 'tar'; | 16 | import tar from 'tar'; |
16 | 17 | ||
17 | import RecipeModel, { type IRecipe } from '../../models/Recipe'; | 18 | import RecipeModel, { type IRecipe } from '../../models/Recipe'; |
@@ -460,7 +461,7 @@ export default class ServerApi { | |||
460 | } | 461 | } |
461 | debug(archivePath); | 462 | debug(archivePath); |
462 | 463 | ||
463 | await sleep(10); | 464 | await sleep(ms('10ms')); |
464 | 465 | ||
465 | await tar.x({ | 466 | await tar.x({ |
466 | file: archivePath, | 467 | file: archivePath, |
@@ -471,14 +472,21 @@ export default class ServerApi { | |||
471 | onwarn: x => debug('warn', recipeId, x), | 472 | onwarn: x => debug('warn', recipeId, x), |
472 | }); | 473 | }); |
473 | 474 | ||
474 | await sleep(10); | 475 | await sleep(ms('10ms')); |
475 | 476 | ||
476 | const { id } = readJsonSync(join(recipeTempDirectory, 'package.json')); | 477 | const { id, defaultIcon } = readJsonSync( |
478 | join(recipeTempDirectory, 'package.json'), | ||
479 | ); | ||
477 | const recipeDirectory = join(recipesDirectory, id); | 480 | const recipeDirectory = join(recipesDirectory, id); |
478 | copySync(recipeTempDirectory, recipeDirectory); | 481 | copySync(recipeTempDirectory, recipeDirectory); |
479 | removeSync(recipeTempDirectory); | 482 | removeSync(recipeTempDirectory); |
480 | removeSync(join(recipesDirectory, recipeId, 'recipe.tar.gz')); | 483 | removeSync(join(recipesDirectory, recipeId, 'recipe.tar.gz')); |
481 | 484 | ||
485 | // TODO: This is a temporary fix to remove svg icons from the user AppData. This should be removed after versions of all recipes have been bumped up | ||
486 | if (defaultIcon) { | ||
487 | removeSync(join(recipeDirectory, 'icon.svg')); | ||
488 | } | ||
489 | |||
482 | return id; | 490 | return id; |
483 | } | 491 | } |
484 | 492 | ||
diff --git a/src/containers/auth/SetupAssistantScreen.tsx b/src/containers/auth/SetupAssistantScreen.tsx index d15b4e6e1..b73b5705d 100644 --- a/src/containers/auth/SetupAssistantScreen.tsx +++ b/src/containers/auth/SetupAssistantScreen.tsx | |||
@@ -1,4 +1,5 @@ | |||
1 | import { inject, observer } from 'mobx-react'; | 1 | import { inject, observer } from 'mobx-react'; |
2 | import ms from 'ms'; | ||
2 | import { Component, type ReactElement } from 'react'; | 3 | import { Component, type ReactElement } from 'react'; |
3 | import type { StoresProps } from '../../@types/ferdium-components.types'; | 4 | import type { StoresProps } from '../../@types/ferdium-components.types'; |
4 | import type { ILegacyServices } from '../../@types/legacy-types'; | 5 | import type { ILegacyServices } from '../../@types/legacy-types'; |
@@ -83,11 +84,11 @@ class SetupAssistantScreen extends Component<IProps, IState> { | |||
83 | }); | 84 | }); |
84 | 85 | ||
85 | // eslint-disable-next-line no-await-in-loop | 86 | // eslint-disable-next-line no-await-in-loop |
86 | await sleep(100); | 87 | await sleep(ms('100ms')); |
87 | } | 88 | } |
88 | 89 | ||
89 | this.setState({ isSettingUpServices: false }); | 90 | this.setState({ isSettingUpServices: false }); |
90 | await sleep(100); | 91 | await sleep(ms('100ms')); |
91 | router.push('/'); | 92 | router.push('/'); |
92 | } | 93 | } |
93 | 94 | ||
diff --git a/src/models/Recipe.ts b/src/models/Recipe.ts index 11eb1884f..87043693b 100644 --- a/src/models/Recipe.ts +++ b/src/models/Recipe.ts | |||
@@ -26,6 +26,7 @@ interface RecipeData { | |||
26 | message?: string; | 26 | message?: string; |
27 | allowFavoritesDelineationInUnreadCount?: boolean; | 27 | allowFavoritesDelineationInUnreadCount?: boolean; |
28 | }; | 28 | }; |
29 | defaultIcon: string; | ||
29 | } | 30 | } |
30 | 31 | ||
31 | export interface IRecipe { | 32 | export interface IRecipe { |
@@ -49,6 +50,7 @@ export interface IRecipe { | |||
49 | path: string; | 50 | path: string; |
50 | partition: string; | 51 | partition: string; |
51 | local: boolean; | 52 | local: boolean; |
53 | defaultIcon: string; | ||
52 | 54 | ||
53 | readonly overrideUserAgent?: () => string; | 55 | readonly overrideUserAgent?: () => string; |
54 | 56 | ||
@@ -76,6 +78,8 @@ export default class Recipe implements IRecipe { | |||
76 | 78 | ||
77 | version = ''; | 79 | version = ''; |
78 | 80 | ||
81 | defaultIcon = ''; | ||
82 | |||
79 | // Removing this specific type will cause a typescript error | 83 | // Removing this specific type will cause a typescript error |
80 | // even while it's the exact same as the interface | 84 | // even while it's the exact same as the interface |
81 | aliases: string[] = []; | 85 | aliases: string[] = []; |
@@ -135,6 +139,7 @@ export default class Recipe implements IRecipe { | |||
135 | // from the recipe | 139 | // from the recipe |
136 | this.id = ifUndefined<string>(data.id, this.id); | 140 | this.id = ifUndefined<string>(data.id, this.id); |
137 | this.name = ifUndefined<string>(data.name, this.name); | 141 | this.name = ifUndefined<string>(data.name, this.name); |
142 | this.defaultIcon = ifUndefined<string>(data.defaultIcon, this.defaultIcon); | ||
138 | this.version = ifUndefined<string>(data.version, this.version); | 143 | this.version = ifUndefined<string>(data.version, this.version); |
139 | this.aliases = ifUndefined<string[]>(data.aliases, this.aliases); | 144 | this.aliases = ifUndefined<string[]>(data.aliases, this.aliases); |
140 | this.serviceURL = ifUndefined<string>( | 145 | this.serviceURL = ifUndefined<string>( |
diff --git a/src/models/Service.ts b/src/models/Service.ts index 525661172..a61df5570 100644 --- a/src/models/Service.ts +++ b/src/models/Service.ts | |||
@@ -377,6 +377,10 @@ export default class Service { | |||
377 | return this.iconUrl; | 377 | return this.iconUrl; |
378 | } | 378 | } |
379 | 379 | ||
380 | if (this.recipe.defaultIcon) { | ||
381 | return this.recipe.defaultIcon; | ||
382 | } | ||
383 | |||
380 | return join(this.recipe.path, 'icon.svg'); | 384 | return join(this.recipe.path, 'icon.svg'); |
381 | } | 385 | } |
382 | 386 | ||