client: stores: directly export singleton stores

This commit is contained in:
Jesse Chan
2020-10-26 19:51:06 +08:00
parent 300502727c
commit 201d562e49
11 changed files with 22 additions and 44 deletions
+2 -4
View File
@@ -14,7 +14,7 @@ export interface Alert {
const DEFAULT_DURATION = 5 * 1000;
class AlertStoreClass {
class AlertStore {
accumulation: Record<string, number> = {};
alerts: Record<string, Alert> = {};
@@ -85,6 +85,4 @@ class AlertStoreClass {
}
}
const AlertStore = new AlertStoreClass();
export default AlertStore;
export default new AlertStore();
+2 -4
View File
@@ -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();
@@ -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();
@@ -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();
+2 -4
View File
@@ -2,7 +2,7 @@ import {makeAutoObservable} from 'mobx';
import type {Feed, Rule, Item} from '@shared/types/Feed';
class FeedStoreClass {
class FeedStore {
feeds: Array<Feed> = [];
rules: Array<Rule> = [];
items: Array<Item> = [];
@@ -43,6 +43,4 @@ class FeedStoreClass {
}
}
const FeedStore = new FeedStoreClass();
export default FeedStore;
export default new FeedStore();
@@ -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<Notification> = [];
notificationCount: NotificationCount = INITIAL_COUNT_STATE;
ongoingPolls = {};
@@ -26,6 +26,4 @@ class NotificationStoreClass {
}
}
const NotificationStore = new NotificationStoreClass();
export default NotificationStore;
export default new NotificationStore();
+2 -4
View File
@@ -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();
@@ -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();
+2 -4
View File
@@ -10,7 +10,7 @@ import SettingStore from './SettingStore';
import sortTorrents from '../util/sortTorrents';
import TorrentFilterStore from './TorrentFilterStore';
class TorrentStoreClass {
class TorrentStore {
selectedTorrents: Array<string> = [];
torrents: TorrentList = {};
@@ -73,6 +73,4 @@ class TorrentStoreClass {
}
}
const TorrentStore = new TorrentStoreClass();
export default TorrentStore;
export default new TorrentStore();
@@ -5,7 +5,7 @@ import type {TransferDirection, TransferHistory, TransferSummary} from '@shared/
export const TRANSFER_DIRECTIONS: Readonly<Array<TransferDirection>> = ['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();
+2 -4
View File
@@ -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();