mirror of
https://github.com/zoriya/flood.git
synced 2025-12-20 14:15:15 +00:00
Use config
This commit is contained in:
@@ -2,11 +2,9 @@ import ActionTypes from '../constants/ActionTypes';
|
||||
import AppDispatcher from '../dispatcher/AppDispatcher';
|
||||
import BaseStore from './BaseStore';
|
||||
import ClientActions from '../actions/ClientActions';
|
||||
import config from '../config/config';
|
||||
import EventTypes from '../constants/EventTypes';
|
||||
|
||||
const historyLength = 100;
|
||||
const pollInterval = 5000;
|
||||
|
||||
class ClientDataStoreClass extends BaseStore {
|
||||
constructor() {
|
||||
super();
|
||||
@@ -54,14 +52,14 @@ class ClientDataStoreClass extends BaseStore {
|
||||
let downloadRateHistory = Object.assign([], this.transferRates.download);
|
||||
let uploadRateHistory = Object.assign([], this.transferRates.upload);
|
||||
|
||||
if (uploadRateHistory.length === historyLength) {
|
||||
if (uploadRateHistory.length === config.maxHistoryStates) {
|
||||
downloadRateHistory.shift();
|
||||
uploadRateHistory.shift();
|
||||
downloadRateHistory.push(parseInt(transferData.downloadRate));
|
||||
uploadRateHistory.push(parseInt(transferData.uploadRate));
|
||||
} else {
|
||||
while (index < historyLength) {
|
||||
if (index < historyLength - 1) {
|
||||
while (index < config.maxHistoryStates) {
|
||||
if (index < config.maxHistoryStates - 1) {
|
||||
uploadRateHistory[index] = 0;
|
||||
downloadRateHistory[index] = 0;
|
||||
} else {
|
||||
@@ -87,7 +85,7 @@ class ClientDataStoreClass extends BaseStore {
|
||||
startPollingTransferData() {
|
||||
this.pollTransferDataID = setInterval(
|
||||
this.fetchTransferData.bind(this),
|
||||
pollInterval
|
||||
config.pollInterval
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import _ from 'lodash';
|
||||
import ActionTypes from '../constants/ActionTypes';
|
||||
import AppDispatcher from '../dispatcher/AppDispatcher';
|
||||
import BaseStore from './BaseStore';
|
||||
import config from '../config/config';
|
||||
import EventTypes from '../constants/EventTypes';
|
||||
import {filterTorrents} from '../util/filterTorrents';
|
||||
import {searchTorrents} from '../util/searchTorrents';
|
||||
@@ -12,16 +13,13 @@ import TorrentActions from '../actions/TorrentActions';
|
||||
import TorrentFilterStore from './TorrentFilterStore';
|
||||
import UIStore from './UIStore';
|
||||
|
||||
const pollInterval = 5000;
|
||||
|
||||
class TorrentStoreClass extends BaseStore {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.filteredTorrents = [];
|
||||
this.pollTorrentDetailsIntervalID = null;
|
||||
this.pollTorrentsIntervalID = null;
|
||||
this.isPollingTorrentDetails = false;
|
||||
this.isPollingTorrents = false;
|
||||
this.selectedTorrents = [];
|
||||
this.torrentDetails = {};
|
||||
this.torrents = [];
|
||||
@@ -29,7 +27,7 @@ class TorrentStoreClass extends BaseStore {
|
||||
|
||||
fetchTorrentDetails() {
|
||||
TorrentActions.fetchTorrentDetails(UIStore.getTorrentDetailsHash());
|
||||
if (!this.isPollingTorrentDetails) {
|
||||
if (this.pollTorrentDetailsIntervalID === null) {
|
||||
this.stopPollingTorrentDetails();
|
||||
this.startPollingTorrentDetails();
|
||||
}
|
||||
@@ -38,7 +36,7 @@ class TorrentStoreClass extends BaseStore {
|
||||
fetchTorrents() {
|
||||
TorrentActions.fetchTorrents();
|
||||
|
||||
if (!this.isPollingTorrents) {
|
||||
if (this.pollTorrentsIntervalID === null) {
|
||||
this.startPollingTorrents();
|
||||
}
|
||||
}
|
||||
@@ -108,29 +106,27 @@ class TorrentStoreClass extends BaseStore {
|
||||
}
|
||||
|
||||
startPollingTorrentDetails() {
|
||||
this.isPollingTorrentDetails = true;
|
||||
this.pollTorrentDetailsIntervalID = setInterval(
|
||||
this.fetchTorrentDetails.bind(this),
|
||||
pollInterval
|
||||
config.pollInterval
|
||||
);
|
||||
}
|
||||
|
||||
startPollingTorrents() {
|
||||
this.isPollingTorrents = true;
|
||||
this.pollTorrentsIntervalID = setInterval(
|
||||
this.fetchTorrents.bind(this),
|
||||
pollInterval
|
||||
config.pollInterval
|
||||
);
|
||||
}
|
||||
|
||||
stopPollingTorrentDetails() {
|
||||
clearInterval(this.pollTorrentDetailsIntervalID);
|
||||
this.isPollingTorrents = false;
|
||||
this.pollTorrentDetailsIntervalID = null;
|
||||
}
|
||||
|
||||
stopPollingTorrents() {
|
||||
clearInterval(this.pollTorrentsIntervalID);
|
||||
this.isPollingTorrentDetails = false;
|
||||
this.pollTorrentsIntervalID = null;
|
||||
}
|
||||
|
||||
triggerTorrentsFilter() {
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user