server: migrate method call configs to immutable arrays

This commit is contained in:
Jesse Chan
2020-10-07 00:25:42 +08:00
parent 6237310fcb
commit 16465f4239
17 changed files with 428 additions and 432 deletions
+4 -10
View File
@@ -1,11 +1,10 @@
import {deepEqual} from 'fast-equals';
import type {TorrentProperties, TorrentListDiff, Torrents} from '@shared/types/Torrent';
import type {TorrentProperties, TorrentListDiff, TorrentListSummary} from '@shared/types/Torrent';
import BaseService from './BaseService';
import config from '../../config';
import methodCallUtil from '../util/methodCallUtil';
import torrentListPropMap from '../constants/torrentListPropMap';
import torrentListMethodCallConfigs from '../constants/torrentListMethodCallConfigs';
import {
getTorrentETAFromProperties,
@@ -22,16 +21,11 @@ interface TorrentServiceEvents {
removeListener: (event: keyof Omit<TorrentServiceEvents, 'newListener' | 'removeListener'>) => void;
}
const torrentListMethodCallConfig = methodCallUtil.getMethodCallConfigFromPropMap(torrentListPropMap);
class TorrentService extends BaseService<TorrentServiceEvents> {
errorCount = 0;
pollEnabled = false;
pollTimeout: NodeJS.Timeout | null = null;
torrentListSummary: {
id: number;
torrents: Torrents;
} = {id: Date.now(), torrents: {}};
torrentListSummary: TorrentListSummary = {id: Date.now(), torrents: {}};
constructor(...args: ConstructorParameters<typeof BaseService>) {
super(...args);
@@ -147,7 +141,7 @@ class TorrentService extends BaseService<TorrentServiceEvents> {
}
return this.services?.clientGatewayService
.fetchTorrentList(torrentListMethodCallConfig)
.fetchTorrentList(torrentListMethodCallConfigs)
.then(this.handleFetchTorrentListSuccess)
.catch(this.handleFetchTorrentListError);
}