mirror of
https://github.com/zoriya/flood.git
synced 2026-05-31 10:22:44 +00:00
Add icon for torrent status
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import React from 'react';
|
||||
|
||||
import ErrorIcon from '../components/icons/ErrorIcon';
|
||||
import PauseIcon from '../components/icons/PauseIcon';
|
||||
import propsMap from '../../../../shared/constants/propsMap';
|
||||
import StartIcon from '../components/icons/StartIcon';
|
||||
import StopIcon from '../components/icons/StopIcon';
|
||||
|
||||
const STATUS_ICON_MAP = {
|
||||
error: <ErrorIcon />,
|
||||
stopped: <StopIcon />,
|
||||
paused: <PauseIcon />,
|
||||
running: <StartIcon />
|
||||
};
|
||||
|
||||
export function torrentStatusIcons(status) {
|
||||
let statusString;
|
||||
let statusConditions = {
|
||||
error: [status.indexOf(propsMap.clientStatus.error) > -1],
|
||||
paused: [status.indexOf(propsMap.clientStatus.paused) > -1],
|
||||
stopped: [status.indexOf(propsMap.clientStatus.stopped) > -1],
|
||||
running: [
|
||||
status.indexOf(propsMap.clientStatus.downloading) > -1,
|
||||
status.indexOf(propsMap.clientStatus.seeding) > -1
|
||||
],
|
||||
hashChecking: [status.indexOf(propsMap.clientStatus.checking) > -1]
|
||||
};
|
||||
|
||||
Object.keys(statusConditions).some((status) => {
|
||||
let conditions = statusConditions[status];
|
||||
conditions.some((condition) => {
|
||||
if (condition) {
|
||||
statusString = status;
|
||||
}
|
||||
return condition;
|
||||
});
|
||||
});
|
||||
|
||||
return STATUS_ICON_MAP[statusString];
|
||||
}
|
||||
Reference in New Issue
Block a user