From 201d562e49e1557c69076dd74a543b990ffc9315 Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Mon, 26 Oct 2020 19:51:06 +0800 Subject: [PATCH] client: stores: directly export singleton stores --- client/src/javascript/stores/AlertStore.ts | 6 ++---- client/src/javascript/stores/AuthStore.ts | 6 ++---- client/src/javascript/stores/ClientStatusStore.ts | 6 ++---- client/src/javascript/stores/DiskUsageStore.ts | 6 ++---- client/src/javascript/stores/FeedStore.ts | 6 ++---- client/src/javascript/stores/NotificationStore.ts | 6 ++---- client/src/javascript/stores/SettingStore.ts | 6 ++---- client/src/javascript/stores/TorrentFilterStore.ts | 6 ++---- client/src/javascript/stores/TorrentStore.ts | 6 ++---- client/src/javascript/stores/TransferDataStore.ts | 6 ++---- client/src/javascript/stores/UIStore.ts | 6 ++---- 11 files changed, 22 insertions(+), 44 deletions(-) diff --git a/client/src/javascript/stores/AlertStore.ts b/client/src/javascript/stores/AlertStore.ts index f47e47a8..2a69097d 100644 --- a/client/src/javascript/stores/AlertStore.ts +++ b/client/src/javascript/stores/AlertStore.ts @@ -14,7 +14,7 @@ export interface Alert { const DEFAULT_DURATION = 5 * 1000; -class AlertStoreClass { +class AlertStore { accumulation: Record = {}; alerts: Record = {}; @@ -85,6 +85,4 @@ class AlertStoreClass { } } -const AlertStore = new AlertStoreClass(); - -export default AlertStore; +export default new AlertStore(); diff --git a/client/src/javascript/stores/AuthStore.ts b/client/src/javascript/stores/AuthStore.ts index e9927354..e07a9ad7 100644 --- a/client/src/javascript/stores/AuthStore.ts +++ b/client/src/javascript/stores/AuthStore.ts @@ -8,7 +8,7 @@ import type {Credentials} from '@shared/schema/Auth'; import ConfigStore from './ConfigStore'; import FloodActions from '../actions/FloodActions'; -class AuthStoreClass { +class AuthStore { isAuthenticating = false; isAuthenticated = false; token: string | null | undefined = null; @@ -88,6 +88,4 @@ class AuthStoreClass { } } -const AuthStore = new AuthStoreClass(); - -export default AuthStore; +export default new AuthStore(); diff --git a/client/src/javascript/stores/ClientStatusStore.ts b/client/src/javascript/stores/ClientStatusStore.ts index 089e4b91..43f90aaf 100644 --- a/client/src/javascript/stores/ClientStatusStore.ts +++ b/client/src/javascript/stores/ClientStatusStore.ts @@ -1,6 +1,6 @@ import {makeAutoObservable} from 'mobx'; -class ClientStatusStoreClass { +class ClientStatusStore { isConnected = true; constructor() { @@ -14,6 +14,4 @@ class ClientStatusStoreClass { } } -const ClientStatusStore = new ClientStatusStoreClass(); - -export default ClientStatusStore; +export default new ClientStatusStore(); diff --git a/client/src/javascript/stores/DiskUsageStore.ts b/client/src/javascript/stores/DiskUsageStore.ts index 31dfbd42..1f896e53 100644 --- a/client/src/javascript/stores/DiskUsageStore.ts +++ b/client/src/javascript/stores/DiskUsageStore.ts @@ -2,7 +2,7 @@ import {makeAutoObservable} from 'mobx'; import type {Disks} from '@shared/types/DiskUsage'; -class DiskUsageStoreClass { +class DiskUsageStore { disks: Disks = []; constructor() { @@ -14,6 +14,4 @@ class DiskUsageStoreClass { } } -const DiskUsageStore = new DiskUsageStoreClass(); - -export default DiskUsageStore; +export default new DiskUsageStore(); diff --git a/client/src/javascript/stores/FeedStore.ts b/client/src/javascript/stores/FeedStore.ts index 8b4d613c..a6e759ca 100644 --- a/client/src/javascript/stores/FeedStore.ts +++ b/client/src/javascript/stores/FeedStore.ts @@ -2,7 +2,7 @@ import {makeAutoObservable} from 'mobx'; import type {Feed, Rule, Item} from '@shared/types/Feed'; -class FeedStoreClass { +class FeedStore { feeds: Array = []; rules: Array = []; items: Array = []; @@ -43,6 +43,4 @@ class FeedStoreClass { } } -const FeedStore = new FeedStoreClass(); - -export default FeedStore; +export default new FeedStore(); diff --git a/client/src/javascript/stores/NotificationStore.ts b/client/src/javascript/stores/NotificationStore.ts index 6506ea1a..fcb1fe34 100644 --- a/client/src/javascript/stores/NotificationStore.ts +++ b/client/src/javascript/stores/NotificationStore.ts @@ -4,7 +4,7 @@ import type {Notification, NotificationCount, NotificationState} from '@shared/t const INITIAL_COUNT_STATE: NotificationCount = {total: 0, unread: 0, read: 0}; -class NotificationStoreClass { +class NotificationStore { notifications: Array = []; notificationCount: NotificationCount = INITIAL_COUNT_STATE; ongoingPolls = {}; @@ -26,6 +26,4 @@ class NotificationStoreClass { } } -const NotificationStore = new NotificationStoreClass(); - -export default NotificationStore; +export default new NotificationStore(); diff --git a/client/src/javascript/stores/SettingStore.ts b/client/src/javascript/stores/SettingStore.ts index 19e5d17c..838a26fc 100644 --- a/client/src/javascript/stores/SettingStore.ts +++ b/client/src/javascript/stores/SettingStore.ts @@ -5,7 +5,7 @@ import defaultFloodSettings from '@shared/constants/defaultFloodSettings'; import type {ClientSettings} from '@shared/types/ClientSettings'; import type {FloodSettings} from '@shared/types/FloodSettings'; -class SettingStoreClass { +class SettingStore { fetchStatus = { clientSettingsFetched: false, floodSettingsFetched: false, @@ -51,6 +51,4 @@ class SettingStoreClass { } } -const SettingStore = new SettingStoreClass(); - -export default SettingStore; +export default new SettingStore(); diff --git a/client/src/javascript/stores/TorrentFilterStore.ts b/client/src/javascript/stores/TorrentFilterStore.ts index cd7240c2..bc971c8b 100644 --- a/client/src/javascript/stores/TorrentFilterStore.ts +++ b/client/src/javascript/stores/TorrentFilterStore.ts @@ -4,7 +4,7 @@ import jsonpatch, {Operation} from 'fast-json-patch'; import type {Taxonomy} from '@shared/types/Taxonomy'; import type {TorrentStatus} from '@shared/constants/torrentStatusMap'; -class TorrentFilterStoreClass { +class TorrentFilterStore { filters: { searchFilter: string; statusFilter: TorrentStatus | ''; @@ -82,6 +82,4 @@ class TorrentFilterStoreClass { } } -const TorrentFilterStore = new TorrentFilterStoreClass(); - -export default TorrentFilterStore; +export default new TorrentFilterStore(); diff --git a/client/src/javascript/stores/TorrentStore.ts b/client/src/javascript/stores/TorrentStore.ts index b8805843..90931428 100644 --- a/client/src/javascript/stores/TorrentStore.ts +++ b/client/src/javascript/stores/TorrentStore.ts @@ -10,7 +10,7 @@ import SettingStore from './SettingStore'; import sortTorrents from '../util/sortTorrents'; import TorrentFilterStore from './TorrentFilterStore'; -class TorrentStoreClass { +class TorrentStore { selectedTorrents: Array = []; torrents: TorrentList = {}; @@ -73,6 +73,4 @@ class TorrentStoreClass { } } -const TorrentStore = new TorrentStoreClass(); - -export default TorrentStore; +export default new TorrentStore(); diff --git a/client/src/javascript/stores/TransferDataStore.ts b/client/src/javascript/stores/TransferDataStore.ts index b0e1accf..ead7d026 100644 --- a/client/src/javascript/stores/TransferDataStore.ts +++ b/client/src/javascript/stores/TransferDataStore.ts @@ -5,7 +5,7 @@ import type {TransferDirection, TransferHistory, TransferSummary} from '@shared/ export const TRANSFER_DIRECTIONS: Readonly> = ['download', 'upload'] as const; -class TransferDataStoreClass { +class TransferDataStore { transferRates: TransferHistory = { download: new Array(30).fill(0), upload: new Array(30).fill(0), @@ -58,6 +58,4 @@ class TransferDataStoreClass { } } -const TransferDataStore = new TransferDataStoreClass(); - -export default TransferDataStore; +export default new TransferDataStore(); diff --git a/client/src/javascript/stores/UIStore.ts b/client/src/javascript/stores/UIStore.ts index 6b1eb24a..34313dcc 100644 --- a/client/src/javascript/stores/UIStore.ts +++ b/client/src/javascript/stores/UIStore.ts @@ -73,7 +73,7 @@ export type Modal = hash: string; }; -class UIStoreClass { +class UIStore { activeContextMenu: ContextMenu | null = null; activeDropdownMenu: string | null = null; activeModal: Modal | null = null; @@ -181,6 +181,4 @@ class UIStoreClass { } } -const UIStore = new UIStoreClass(); - -export default UIStore; +export default new UIStore();