diff options
Diffstat (limited to 'src/api')
-rw-r--r-- | src/api/NewsApi.ts | 18 | ||||
-rw-r--r-- | src/api/index.ts | 2 | ||||
-rw-r--r-- | src/api/server/ServerApi.js | 36 |
3 files changed, 1 insertions, 55 deletions
diff --git a/src/api/NewsApi.ts b/src/api/NewsApi.ts deleted file mode 100644 index 31d3d903b..000000000 --- a/src/api/NewsApi.ts +++ /dev/null | |||
@@ -1,18 +0,0 @@ | |||
1 | export default class NewsApi { | ||
2 | server: any; | ||
3 | |||
4 | local: any; | ||
5 | |||
6 | constructor(server: any, local: any) { | ||
7 | this.server = server; | ||
8 | this.local = local; | ||
9 | } | ||
10 | |||
11 | latest() { | ||
12 | return this.server.getLatestNews(); | ||
13 | } | ||
14 | |||
15 | hide(id: any) { | ||
16 | return this.server.hideNews(id); | ||
17 | } | ||
18 | } | ||
diff --git a/src/api/index.ts b/src/api/index.ts index 73f613da1..59fad194a 100644 --- a/src/api/index.ts +++ b/src/api/index.ts | |||
@@ -4,7 +4,6 @@ import RecipePreviewsApi from './RecipePreviewsApi'; | |||
4 | import RecipesApi from './RecipesApi'; | 4 | import RecipesApi from './RecipesApi'; |
5 | import UserApi from './UserApi'; | 5 | import UserApi from './UserApi'; |
6 | import LocalApi from './LocalApi'; | 6 | import LocalApi from './LocalApi'; |
7 | import NewsApi from './NewsApi'; | ||
8 | import FeaturesApi from './FeaturesApi'; | 7 | import FeaturesApi from './FeaturesApi'; |
9 | 8 | ||
10 | export default (server: any, local: any) => ({ | 9 | export default (server: any, local: any) => ({ |
@@ -15,5 +14,4 @@ export default (server: any, local: any) => ({ | |||
15 | features: new FeaturesApi(server), | 14 | features: new FeaturesApi(server), |
16 | user: new UserApi(server, local), | 15 | user: new UserApi(server, local), |
17 | local: new LocalApi(server, local), | 16 | local: new LocalApi(server, local), |
18 | news: new NewsApi(server, local), | ||
19 | }); | 17 | }); |
diff --git a/src/api/server/ServerApi.js b/src/api/server/ServerApi.js index e321f9372..6bbf572fa 100644 --- a/src/api/server/ServerApi.js +++ b/src/api/server/ServerApi.js | |||
@@ -16,14 +16,12 @@ import fetch from 'electron-fetch'; | |||
16 | import ServiceModel from '../../models/Service'; | 16 | import ServiceModel from '../../models/Service'; |
17 | import RecipePreviewModel from '../../models/RecipePreview'; | 17 | import RecipePreviewModel from '../../models/RecipePreview'; |
18 | import RecipeModel from '../../models/Recipe'; | 18 | import RecipeModel from '../../models/Recipe'; |
19 | import NewsModel from '../../models/News'; | ||
20 | import UserModel from '../../models/User'; | 19 | import UserModel from '../../models/User'; |
21 | 20 | ||
22 | import { sleep } from '../../helpers/async-helpers'; | 21 | import { sleep } from '../../helpers/async-helpers'; |
23 | 22 | ||
24 | import { SERVER_NOT_LOADED } from '../../config'; | 23 | import { SERVER_NOT_LOADED } from '../../config'; |
25 | import { osArch, osPlatform } from '../../environment'; | 24 | import { userDataRecipesPath, userDataPath } from '../../environment-remote'; |
26 | import { userDataRecipesPath, userDataPath, ferdiVersion } from '../../environment-remote'; | ||
27 | import { asarRecipesPath } from '../../helpers/asar-helpers'; | 25 | import { asarRecipesPath } from '../../helpers/asar-helpers'; |
28 | import apiBase from '../apiBase'; | 26 | import apiBase from '../apiBase'; |
29 | import { prepareAuthRequest, sendAuthRequest } from '../utils/auth'; | 27 | import { prepareAuthRequest, sendAuthRequest } from '../utils/auth'; |
@@ -442,25 +440,6 @@ export default class ServerApi { | |||
442 | } | 440 | } |
443 | } | 441 | } |
444 | 442 | ||
445 | // News | ||
446 | async getLatestNews() { | ||
447 | const url = `${apiBase( | ||
448 | true, | ||
449 | )}/news?platform=${osPlatform}&arch=${osArch}&version=${ferdiVersion}`; | ||
450 | const request = await sendAuthRequest(url); | ||
451 | if (!request.ok) throw request; | ||
452 | const data = await request.json(); | ||
453 | const news = this._mapNewsModels(data); | ||
454 | debug('ServerApi::getLatestNews resolves', news); | ||
455 | return news; | ||
456 | } | ||
457 | |||
458 | async hideNews(id) { | ||
459 | const request = await sendAuthRequest(`${apiBase()}/news/${id}/read`); | ||
460 | if (!request.ok) throw request; | ||
461 | debug('ServerApi::hideNews resolves', id); | ||
462 | } | ||
463 | |||
464 | // Health Check | 443 | // Health Check |
465 | async healthCheck() { | 444 | async healthCheck() { |
466 | if (apiBase() === SERVER_NOT_LOADED) { | 445 | if (apiBase() === SERVER_NOT_LOADED) { |
@@ -587,19 +566,6 @@ export default class ServerApi { | |||
587 | .filter(recipe => recipe !== null); | 566 | .filter(recipe => recipe !== null); |
588 | } | 567 | } |
589 | 568 | ||
590 | _mapNewsModels(news) { | ||
591 | return news | ||
592 | .map(newsItem => { | ||
593 | try { | ||
594 | return new NewsModel(newsItem); | ||
595 | } catch (error) { | ||
596 | console.error(error); | ||
597 | return null; | ||
598 | } | ||
599 | }) | ||
600 | .filter(newsItem => newsItem !== null); | ||
601 | } | ||
602 | |||
603 | _getDevRecipes() { | 569 | _getDevRecipes() { |
604 | const recipesDirectory = getDevRecipeDirectory(); | 570 | const recipesDirectory = getDevRecipeDirectory(); |
605 | try { | 571 | try { |