aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores
diff options
context:
space:
mode:
authorLibravatar Markus Hatvan <markus_hatvan@aon.at>2021-10-14 18:20:26 +0200
committerLibravatar GitHub <noreply@github.com>2021-10-14 18:20:26 +0200
commitc27972c12b2d0dba2aee9e3dcffadcf7806a9afd (patch)
tree46fcfe261ae55e6faab604e9c75f94f6ffe326ee /src/stores
parentchore: upgrade 'electron-builder' to '22.14.5' to fix upstream issues. (#2068) (diff)
downloadferdium-app-c27972c12b2d0dba2aee9e3dcffadcf7806a9afd.tar.gz
ferdium-app-c27972c12b2d0dba2aee9e3dcffadcf7806a9afd.tar.zst
ferdium-app-c27972c12b2d0dba2aee9e3dcffadcf7806a9afd.zip
chore: remove all code related to news (#2069)
Diffstat (limited to 'src/stores')
-rw-r--r--src/stores/AppStore.js3
-rw-r--r--src/stores/NewsStore.js55
-rw-r--r--src/stores/index.ts2
3 files changed, 0 insertions, 60 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js
index a86a54c6d..81cef3775 100644
--- a/src/stores/AppStore.js
+++ b/src/stores/AppStore.js
@@ -153,9 +153,6 @@ export default class AppStore extends Store {
153 this.stores.features.featuresRequest.invalidate({ 153 this.stores.features.featuresRequest.invalidate({
154 immediately: true, 154 immediately: true,
155 }); 155 });
156 this.stores.news.latestNewsRequest.invalidate({
157 immediately: true,
158 });
159 }, ms('60m')); 156 }, ms('60m'));
160 157
161 // Check for updates once every 4 hours 158 // Check for updates once every 4 hours
diff --git a/src/stores/NewsStore.js b/src/stores/NewsStore.js
deleted file mode 100644
index 66a17cb29..000000000
--- a/src/stores/NewsStore.js
+++ /dev/null
@@ -1,55 +0,0 @@
1import { computed, observable } from 'mobx';
2import { remove } from 'lodash';
3
4import Store from './lib/Store';
5import CachedRequest from './lib/CachedRequest';
6import Request from './lib/Request';
7import { CHECK_INTERVAL } from '../config';
8
9export default class NewsStore extends Store {
10 @observable latestNewsRequest = new CachedRequest(this.api.news, 'latest');
11
12 @observable hideNewsRequest = new Request(this.api.news, 'hide');
13
14 constructor(...args) {
15 super(...args);
16
17 // Register action handlers
18 this.actions.news.hide.listen(this._hide.bind(this));
19 this.actions.user.logout.listen(this._resetNewsRequest.bind(this));
20 }
21
22 setup() {
23 // Check for news updates every couple of hours
24 setInterval(() => {
25 if (this.latestNewsRequest.wasExecuted && this.stores.user.isLoggedIn) {
26 this.latestNewsRequest.invalidate({ immediately: true });
27 }
28 }, CHECK_INTERVAL);
29 }
30
31 @computed get latest() {
32 return this.latestNewsRequest.execute().result || [];
33 }
34
35 // Actions
36 _hide({ newsId }) {
37 this.hideNewsRequest.execute(newsId);
38
39 this.latestNewsRequest.invalidate().patch((result) => {
40 // TODO: check if we can use mobx.array remove
41 remove(result, (n) => n.id === newsId);
42 });
43 }
44
45 /**
46 * Reset the news request when current user logs out so that when another user
47 * logs in again without an app restart, the request will be fetched again and
48 * the news will be shown to the user.
49 *
50 * @private
51 */
52 _resetNewsRequest() {
53 this.latestNewsRequest.reset();
54 }
55}
diff --git a/src/stores/index.ts b/src/stores/index.ts
index 1760ddfa2..6ad898d85 100644
--- a/src/stores/index.ts
+++ b/src/stores/index.ts
@@ -6,7 +6,6 @@ import ServicesStore from './ServicesStore';
6import RecipesStore from './RecipesStore'; 6import RecipesStore from './RecipesStore';
7import RecipePreviewsStore from './RecipePreviewsStore'; 7import RecipePreviewsStore from './RecipePreviewsStore';
8import UIStore from './UIStore'; 8import UIStore from './UIStore';
9import NewsStore from './NewsStore';
10import RequestStore from './RequestStore'; 9import RequestStore from './RequestStore';
11import GlobalErrorStore from './GlobalErrorStore'; 10import GlobalErrorStore from './GlobalErrorStore';
12import { workspaceStore } from '../features/workspaces'; 11import { workspaceStore } from '../features/workspaces';
@@ -25,7 +24,6 @@ export default (api, actions, router) => {
25 recipes: new RecipesStore(stores, api, actions), 24 recipes: new RecipesStore(stores, api, actions),
26 recipePreviews: new RecipePreviewsStore(stores, api, actions), 25 recipePreviews: new RecipePreviewsStore(stores, api, actions),
27 ui: new UIStore(stores, api, actions), 26 ui: new UIStore(stores, api, actions),
28 news: new NewsStore(stores, api, actions),
29 requests: new RequestStore(stores, api, actions), 27 requests: new RequestStore(stores, api, actions),
30 globalError: new GlobalErrorStore(stores, api, actions), 28 globalError: new GlobalErrorStore(stores, api, actions),
31 workspaces: workspaceStore, 29 workspaces: workspaceStore,