mirror of
https://github.com/zoriya/flood.git
synced 2026-05-27 17:11:58 +00:00
Handle empty torrent list response
This commit is contained in:
@@ -114,6 +114,10 @@ export default class TrackerFilters extends React.Component {
|
||||
render() {
|
||||
let filters = this.getFilters();
|
||||
|
||||
if (filters.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<ul className="sidebar-filter sidebar__item">
|
||||
<li className="sidebar-filter__item sidebar-filter__item--heading">
|
||||
|
||||
@@ -19,17 +19,18 @@ import UIStore from '../../stores/UIStore';
|
||||
|
||||
const METHODS_TO_BIND = [
|
||||
'bindExternalPriorityChangeHandler',
|
||||
'onReceiveTorrentsError',
|
||||
'onReceiveTorrentsSuccess',
|
||||
'getListPadding',
|
||||
'getViewportLimits',
|
||||
'handleContextMenuItemClick',
|
||||
'handleDetailsClick',
|
||||
'handleRightClick',
|
||||
'handleTorrentClick',
|
||||
'onContextMenuChange',
|
||||
'onEmptyTorrentResponse',
|
||||
'onReceiveTorrentsError',
|
||||
'onReceiveTorrentsSuccess',
|
||||
'onTorrentFilterChange',
|
||||
'onTorrentSelectionChange',
|
||||
'getListPadding',
|
||||
'getViewportLimits',
|
||||
'setScrollPosition',
|
||||
'setViewportHeight'
|
||||
];
|
||||
@@ -39,6 +40,7 @@ export default class TorrentListContainer extends React.Component {
|
||||
super();
|
||||
|
||||
this.state = {
|
||||
emptyTorrentList: false,
|
||||
handleTorrentPriorityChange: null,
|
||||
contextMenu: null,
|
||||
maxTorrentIndex: 10,
|
||||
@@ -46,7 +48,7 @@ export default class TorrentListContainer extends React.Component {
|
||||
scrollPosition: 0,
|
||||
torrentCount: 0,
|
||||
torrentHeight: 72,
|
||||
torrents: null,
|
||||
torrents: [],
|
||||
torrentRequestError: false,
|
||||
torrentRequestSuccess: false,
|
||||
viewportHeight: 0
|
||||
@@ -72,6 +74,7 @@ export default class TorrentListContainer extends React.Component {
|
||||
TorrentStore.listen(EventTypes.UI_TORRENT_SELECTION_CHANGE, this.onTorrentSelectionChange);
|
||||
TorrentStore.listen(EventTypes.CLIENT_TORRENTS_REQUEST_SUCCESS, this.onReceiveTorrentsSuccess);
|
||||
TorrentStore.listen(EventTypes.CLIENT_TORRENTS_REQUEST_ERROR, this.onReceiveTorrentsError);
|
||||
TorrentStore.listen(EventTypes.CLIENT_TORRENTS_EMPTY, this.onEmptyTorrentResponse);
|
||||
TorrentFilterStore.listen(EventTypes.UI_TORRENTS_FILTER_CHANGE, this.onTorrentFilterChange);
|
||||
UIStore.listen(EventTypes.UI_CONTEXT_MENU_CHANGE, this.onContextMenuChange);
|
||||
TorrentStore.fetchTorrents();
|
||||
@@ -84,6 +87,7 @@ export default class TorrentListContainer extends React.Component {
|
||||
TorrentStore.unlisten(EventTypes.UI_TORRENT_SELECTION_CHANGE, this.onTorrentSelectionChange);
|
||||
TorrentStore.unlisten(EventTypes.CLIENT_TORRENTS_REQUEST_SUCCESS, this.onReceiveTorrentsSuccess);
|
||||
TorrentStore.unlisten(EventTypes.CLIENT_TORRENTS_REQUEST_ERROR, this.onReceiveTorrentsError);
|
||||
TorrentStore.unlisten(EventTypes.CLIENT_TORRENTS_EMPTY, this.onEmptyTorrentResponse);
|
||||
TorrentFilterStore.unlisten(EventTypes.UI_TORRENTS_FILTER_CHANGE, this.onTorrentFilterChange);
|
||||
UIStore.unlisten(EventTypes.UI_CONTEXT_MENU_CHANGE, this.onContextMenuChange);
|
||||
}
|
||||
@@ -194,6 +198,18 @@ export default class TorrentListContainer extends React.Component {
|
||||
this.setState({contextMenu: UIStore.getActiveContextMenu()});
|
||||
}
|
||||
|
||||
onEmptyTorrentResponse() {
|
||||
this.setState({
|
||||
emptyTorrentList: true,
|
||||
torrentRequestError: false,
|
||||
torrentRequestSuccess: true
|
||||
});
|
||||
|
||||
if (!UIStore.hasSatisfiedDependencies()) {
|
||||
UIStore.satisfyDependency('torrent-list');
|
||||
}
|
||||
}
|
||||
|
||||
onReceiveTorrentsError() {
|
||||
this.setState({torrentRequestError: true, torrentRequestSuccess: false});
|
||||
}
|
||||
@@ -221,6 +237,16 @@ export default class TorrentListContainer extends React.Component {
|
||||
this.forceUpdate();
|
||||
}
|
||||
|
||||
getEmptyTorrentListNotification() {
|
||||
return (
|
||||
<div className="torrents__notification__wrapper">
|
||||
<div className="torrents__notification">
|
||||
No torrents to display.
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
getListPadding(minTorrentIndex, maxTorrentIndex, torrentCount) {
|
||||
// Calculate the number of pixels to pad the visible item list.
|
||||
// If the minimum item index is less than 0, then we're already at the top
|
||||
@@ -345,6 +371,10 @@ export default class TorrentListContainer extends React.Component {
|
||||
);
|
||||
}
|
||||
|
||||
if (this.state.emptyTorrentList) {
|
||||
content = this.getEmptyTorrentListNotification();
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="torrent__list__wrapper">
|
||||
<CustomScrollbars className="torrent__list__wrapper--custom-scroll"
|
||||
|
||||
Reference in New Issue
Block a user