Merge pull request #26 from jfurrow/bug/sort-on-page-load

Fix initial torrent sort
This commit is contained in:
John Furrow
2016-06-12 01:00:30 -07:00
committed by GitHub
7 changed files with 10 additions and 7 deletions
@@ -40,7 +40,6 @@ export default class SettingsModal extends React.Component {
this.handleSettingsStoreChange);
SettingsStore.listen(EventTypes.SETTINGS_SAVE_REQUEST_ERROR,
this.handleSaveSettingsError);
SettingsStore.fetchFloodSettings('speedLimits');
}
componentWillUnmount() {
@@ -30,7 +30,6 @@ class SpeedLimitDropdown extends React.Component {
this.handleSettingsFetchRequestSuccess);
TransferDataStore.listen(EventTypes.CLIENT_TRANSFER_DATA_REQUEST_SUCCESS,
this.onTransferDataRequestSuccess);
SettingsStore.fetchFloodSettings('speedLimits');
TransferDataStore.fetchTransferData();
}
@@ -40,7 +40,6 @@ export default class ActionBar extends React.Component {
componentDidMount() {
this.onSortChange();
SettingsStore.listen(EventTypes.SETTINGS_CHANGE, this.onSortChange);
SettingsStore.fetchFloodSettings('sortTorrents');
}
componentWillUnmount() {
@@ -112,8 +112,7 @@ export default class SortDropdown extends React.Component {
<Dropdown
handleItemSelect={this.handleItemSelect}
header={this.getDropdownHeader()}
menuItems={this.getDropdownMenus()}
/>
menuItems={this.getDropdownMenus()} />
);
}
}
@@ -61,7 +61,6 @@ class SettingsStoreClass extends BaseStore {
this.fetchStatus.clientSettingsFetched = true;
this.clientSettings = settings;
this.emit(EventTypes.CLIENT_SETTINGS_FETCH_REQUEST_SUCCESS);
this.processSettingsState();
}
@@ -48,6 +48,10 @@ class TorrentFilterStoreClass extends BaseStore {
return this.torrentTrackerCount;
}
handleFetchSettingsRequest() {
this.setTorrentsSort(SettingsStore.getFloodSettings('sortTorrents'));
}
handleSortPropsRequestSuccess(sortBy) {
this.setTorrentsSort(sortBy);
}
@@ -131,6 +135,10 @@ TorrentFilterStore.dispatcherID = AppDispatcher.register((payload) => {
case ActionTypes.CLIENT_FETCH_TORRENT_TRACKER_COUNT_REQUEST_ERROR:
TorrentFilterStore.handleTorrentTrackerCountRequestError(action.error);
break;
case ActionTypes.SETTINGS_FETCH_REQUEST_SUCCESS:
AppDispatcher.waitFor([SettingsStore.dispatcherID]);
TorrentFilterStore.handleFetchSettingsRequest();
break;
}
});
+1 -1
View File
@@ -229,7 +229,7 @@ class TorrentStoreClass extends BaseStore {
sortTorrents(torrents) {
let torrentsSort = TorrentFilterStore.getTorrentsSort();
this.torrents = torrents;
this.torrents = torrents || this.torrents;
// Convert torrents hash to array and sort it.
this.sortedTorrents = sortTorrents(this.torrents,