From c27972c12b2d0dba2aee9e3dcffadcf7806a9afd Mon Sep 17 00:00:00 2001 From: Markus Hatvan Date: Thu, 14 Oct 2021 18:20:26 +0200 Subject: chore: remove all code related to news (#2069) --- src/stores/AppStore.js | 3 --- src/stores/NewsStore.js | 55 ------------------------------------------------- src/stores/index.ts | 2 -- 3 files changed, 60 deletions(-) delete mode 100644 src/stores/NewsStore.js (limited to 'src/stores') 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 { this.stores.features.featuresRequest.invalidate({ immediately: true, }); - this.stores.news.latestNewsRequest.invalidate({ - immediately: true, - }); }, ms('60m')); // 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 @@ -import { computed, observable } from 'mobx'; -import { remove } from 'lodash'; - -import Store from './lib/Store'; -import CachedRequest from './lib/CachedRequest'; -import Request from './lib/Request'; -import { CHECK_INTERVAL } from '../config'; - -export default class NewsStore extends Store { - @observable latestNewsRequest = new CachedRequest(this.api.news, 'latest'); - - @observable hideNewsRequest = new Request(this.api.news, 'hide'); - - constructor(...args) { - super(...args); - - // Register action handlers - this.actions.news.hide.listen(this._hide.bind(this)); - this.actions.user.logout.listen(this._resetNewsRequest.bind(this)); - } - - setup() { - // Check for news updates every couple of hours - setInterval(() => { - if (this.latestNewsRequest.wasExecuted && this.stores.user.isLoggedIn) { - this.latestNewsRequest.invalidate({ immediately: true }); - } - }, CHECK_INTERVAL); - } - - @computed get latest() { - return this.latestNewsRequest.execute().result || []; - } - - // Actions - _hide({ newsId }) { - this.hideNewsRequest.execute(newsId); - - this.latestNewsRequest.invalidate().patch((result) => { - // TODO: check if we can use mobx.array remove - remove(result, (n) => n.id === newsId); - }); - } - - /** - * Reset the news request when current user logs out so that when another user - * logs in again without an app restart, the request will be fetched again and - * the news will be shown to the user. - * - * @private - */ - _resetNewsRequest() { - this.latestNewsRequest.reset(); - } -} 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'; import RecipesStore from './RecipesStore'; import RecipePreviewsStore from './RecipePreviewsStore'; import UIStore from './UIStore'; -import NewsStore from './NewsStore'; import RequestStore from './RequestStore'; import GlobalErrorStore from './GlobalErrorStore'; import { workspaceStore } from '../features/workspaces'; @@ -25,7 +24,6 @@ export default (api, actions, router) => { recipes: new RecipesStore(stores, api, actions), recipePreviews: new RecipePreviewsStore(stores, api, actions), ui: new UIStore(stores, api, actions), - news: new NewsStore(stores, api, actions), requests: new RequestStore(stores, api, actions), globalError: new GlobalErrorStore(stores, api, actions), workspaces: workspaceStore, -- cgit v1.2.3-70-g09d2