Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
yadPe committed Aug 10, 2019
1 parent 229ff48 commit a255ba8
Show file tree
Hide file tree
Showing 21 changed files with 30 additions and 49 deletions.
3 changes: 1 addition & 2 deletions src/App/components/Browse/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useState, useEffect } from 'react';
import React from 'react';
import { connect } from 'react-redux';
import test from '../testSearchResult'
import Beatmap from '../common/Beatmap'
import Search from './Search';
import VizSensor from 'react-visibility-sensor';
Expand Down
2 changes: 1 addition & 1 deletion src/App/components/Downloads/DownloadedItems.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext, memo, useCallback } from 'react'
import React, { useContext } from 'react'
import { HistoryContext } from '../../../Providers/HistoryProvider';
import DownloadsItem from './Item';

Expand Down
2 changes: 1 addition & 1 deletion src/App/components/Downloads/DownloadsInQueue.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext, useCallback } from 'react';
import React, { useContext } from 'react';
import DownloadsItem from './Item';
import { DownloadQueueContext } from '../../../Providers/DownloadQueueProvider'

Expand Down
4 changes: 1 addition & 3 deletions src/App/components/Downloads/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import React, { useContext } from 'react'
import React from 'react'
import DownloadedItems from './DownloadedItems';
import DownloadsInQueue from './DownloadsInQueue';
import DownloadsInProgress from './DownloadsInProgress';
import { HistoryContext } from '../../../Providers/HistoryProvider';

const Downloads = ({ theme }) => {
//const { history } = useContext(HistoryContext);
return (
<React.Fragment>
<DownloadsInProgress theme={theme} />
Expand Down
1 change: 0 additions & 1 deletion src/App/components/Matchs/AddMatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { connect } from 'react-redux';
const AddMatch = ({ bot, theme, errors, ircUsername }) => {
const [ reqMatchId, setReqMatchId ] = useState('');
const error = errors.filter(id => id === reqMatchId).length === 1
const test = /^[0-9]{4,10}$/g;
return (
<React.Fragment>
<TextInput
Expand Down
4 changes: 1 addition & 3 deletions src/App/components/Matchs/MatchDetails/ControlsBar.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react'
import injectSheet from 'react-jss';
import { Button, Text } from 'react-desktop/windows';
import { Button } from 'react-desktop/windows';
import renderIcons from '../../../utils/renderIcons';
import store from '../../../../store';

const styles = {
ControlsBar: {
Expand Down Expand Up @@ -46,7 +45,6 @@ const ControlsBar = ({ classes, theme, match, close }) => {
push
color={theme.color}
onClick={match.toggleAutoBeat}
// hidden={!beatmap.title}
>
{`AutoBeat: ${match.autoBeat ? ' on' : 'off'}`}
</Button>
Expand Down
2 changes: 1 addition & 1 deletion src/App/components/Matchs/MatchDetails/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react'
import React from 'react'
import Beatmap from '../../common/Beatmap'
import PlayersList from './PlayersList'
import ControlsBar from './ControlsBar';
Expand Down
2 changes: 1 addition & 1 deletion src/App/components/Matchs/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Affiche la liste des matchs si aucun match n'est selectionné

import React, { useState, useEffect } from 'react'
import React, { useState } from 'react'
import AddMatch from './AddMatch'
import MatchListItem from './MatchListItem'

Expand Down
2 changes: 1 addition & 1 deletion src/App/components/Nav.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react';
import { connect } from 'react-redux';
import { NavPane, NavPaneItem, Text } from 'react-desktop/windows';
import { NavPane, NavPaneItem } from 'react-desktop/windows';
import Start from './Start'
import Matchs from './Matchs'
import Browse from './Browse'
Expand Down
2 changes: 0 additions & 2 deletions src/App/components/Settings/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import React, { useEffect } from 'react';
import { connect } from 'react-redux'
import { remote } from 'electron';
import store from '../../../store';
import Volume from './Volume'
import History from './History';
import { Button } from 'react-desktop/windows';
import ConfLoader from './ConfLoader';
import { updateVolume } from './actions';
import Configuration from './Configuration';
Expand Down
3 changes: 2 additions & 1 deletion src/App/components/Start/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, createRef } from 'react'
import start from '../../../Bot';
import { ProgressCircle, Button, Text } from 'react-desktop/windows';
import { ProgressCircle, Button } from 'react-desktop/windows';
import { connect } from 'react-redux';

const Start = ({ connected, theme, irc, osuApi }) => {
Expand All @@ -9,6 +9,7 @@ const Start = ({ connected, theme, irc, osuApi }) => {

useEffect(() => {
that.current.parentNode.style.padding = 0; // Dirty way to custom react-desktop component
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

return (
Expand Down
1 change: 1 addition & 0 deletions src/App/components/common/Beatmap/Cover.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const Cover = ({ url, width, height }) => {
useEffect(() => {
isLoaded(false)
cover.setAttribute('src', url);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [url]);

const style = {
Expand Down
2 changes: 1 addition & 1 deletion src/App/components/common/Beatmap/DownloadBeatmapBtn.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useContext } from 'react';
import renderIcons from '../../../utils/renderIcons'
import { ProgressCircle, Button, Text } from 'react-desktop/windows';
import { ProgressCircle, Button } from 'react-desktop/windows';
import { DownloadQueueContext } from '../../../../Providers/DownloadQueueProvider'
import { HistoryContext } from '../../../../Providers/HistoryProvider';

Expand Down
2 changes: 1 addition & 1 deletion src/App/components/common/Beatmap/PreviewBeatmapBtn.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState, useContext } from 'react';
import { Button, Text } from 'react-desktop/windows';
import { Button } from 'react-desktop/windows';
import renderIcons from '../../../utils/renderIcons'
import { AudioPlayerContext } from '../../../../Providers/AudioPlayerProvider';

Expand Down
15 changes: 5 additions & 10 deletions src/App/components/common/Beatmap/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect, memo } from 'react';
import React, { useState, useEffect, memo, useRef } from 'react';
import Cover from './Cover'
import { Button, Text } from 'react-desktop/windows';
import DownloadBeatmapBtn from './DownloadBeatmapBtn'
Expand All @@ -18,14 +18,8 @@ const Beatmap = ({ theme, beatmap, width }) => {
const [brightness, setBrightness] = useState(0.95)
const [isPlaying, setIsPLaying] = useState(false)
const { beatmapset_id, id, title, artist, creator, version, beatconnectDlLink } = beatmap;
// const playpreview = null;
// const downloadBeatmap = null;

let bpmFlash = null;

// const handleClick = () => {

// }

const bpmFlash = useRef(null);

const style = isPlaying ? {
width: width || '80%',
Expand All @@ -46,12 +40,13 @@ const Beatmap = ({ theme, beatmap, width }) => {

useEffect(() => {
if (isPlaying) {
bpmFlash = setInterval(() => {
bpmFlash.current = setInterval(() => {
setBrightness(1.08)
setTimeout(() => setBrightness(0.95), (60000 / beatmap.bpm) / 2.5)
}, 60000 / beatmap.bpm)
}
return () => bpmFlash ? clearInterval(bpmFlash) : undefined
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isPlaying])

useEffect(() => {
Expand Down
2 changes: 2 additions & 0 deletions src/App/utils/renderIcons.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,7 @@ export default function(name, style) {
L311.1,311.1z"/>
</svg>
);
default:
return null
}
}
2 changes: 1 addition & 1 deletion src/App/utils/timeSince.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default (timeStamp) => {
if (secondsPast > 86400) {
const day = timeStamp.getDate();
const month = timeStamp.toDateString().match(/ [a-zA-Z]*/)[0].replace(" ", "");
const year = timeStamp.getFullYear() == now.getFullYear() ? "" : " " + timeStamp.getFullYear();
const year = timeStamp.getFullYear() === now.getFullYear() ? "" : " " + timeStamp.getFullYear();
return day + " " + month + year;
}
}
2 changes: 1 addition & 1 deletion src/Bot/BeatconnectApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const getDlLink = (beatmapInfos, pretty, extra) => {
'4': 'Loved', '3': 'Qualified', '2': 'Approved', '1': 'Ranked', '0': 'Pending', '-1': 'WIP', '-2': 'Graveyard'
};
if (extra) {
const { creator, approved, version, creator_id, bpm, max_combo, difficultyrating, diff_approach, mode } = extra;
const { creator, approved, version, creator_id, bpm, max_combo, diff_approach } = extra;
return `[${status[approved] || ''}] [https://beatconnect.io/b/${id}/${unique_id} ${artist || ''} - ${title || ''} [${version || ''}]] by [https://osu.ppy.sh/u/${creator_id} ${creator || 'peppy'}] | BPM ${bpm || 0} | AR ${diff_approach || 0} ${max_combo ? '| Max combo: ' + max_combo : ''}`;
}
if (pretty) return `[https://beatconnect.io/b/${id}/${unique_id} ${artist} - ${title}]`;
Expand Down
10 changes: 5 additions & 5 deletions src/Bot/Bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { BeatconnectApi, getDlLink } = require('./BeatconnectApi');

class Bot {
constructor(configFile) {
this.regExp = [/.*?((?:\/[\w\.\-]+)+)/i, /.*?(?:\/[\w\.\-]+)+.*?(?:\/[\w\.\-]+)+.*?((?:\/[\w\.\-]+)+)/i];
this.regExps = [/.*?(?:\/[\w.-]+)+.*?(?:\/[\w.-]+)+.*?((?:\/[\w.-]+)+)/i];
this.conf = configFile;
this.targetServer = this.conf.userPreferences.targetServer;
this.beatconnect = new BeatconnectApi(this.conf.beatconnectAPI.key);
Expand Down Expand Up @@ -44,7 +44,7 @@ class Bot {

newMatch(id, matchName, ircRoom, creator, playerList) {
console.log(`New match created : ${id} ${matchName} ${ircRoom} ${creator}`);
const alreadyExist = false;
let alreadyExist = false;
this.matchs.map(match => {
if (match.id === id)
alreadyExist = true
Expand Down Expand Up @@ -102,12 +102,12 @@ class Bot {
onMpMessage(matchId, msg) {
this.matchs.map(match => {
if (match.id === matchId) {
const { rawMsg, from, channel, text } = msg;
const { rawMsg } = msg;
const { rawCommand, args } = rawMsg;

if (rawCommand === 'PRIVMSG' && args[0].includes('mp')) {
if (args[1].includes('Beatmap changed to')) {
const beatmapId = this.regExp[1].exec(args[1])[1].split('/').pop();
const beatmapId = this.regExps[0].exec(args[1])[1].split('/').pop();
this.newBeatmap(beatmapId, matchId);
} else if (args[1].includes('joined in')) {
const player = args[1].split(' ').shift();
Expand Down Expand Up @@ -170,7 +170,7 @@ class Bot {
if (!fromMp) { this.irc.pm(from, `You need to be in a multiplayer match to use this`); break; }
const matchId = fromMp.split('_').pop();
this.matchs.map(match => {
if (match.id = matchId)
if (match.id === matchId)
this.sendMapById(match.beatmapset_id, fromMp, match.fullBeatmapData);
});
break;
Expand Down
1 change: 1 addition & 0 deletions src/Bot/msg/mpSettings.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable array-callback-return */
import store from "../../store";

export default function(msg) {
Expand Down
15 changes: 2 additions & 13 deletions src/Providers/HistoryProvider.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Provides download history from {localUser}/Documents/Beatconnect/history.json */
import React, { Component } from 'react';
import { remote, shell } from 'electron';
import { outputJSON, readJson, ensureDir } from 'fs-extra';
import { remote } from 'electron';
import { outputJSON, readJson } from 'fs-extra';

export const HistoryContext = React.createContext();

Expand All @@ -28,17 +28,6 @@ class HistoryProvider extends Component {
}
}

// componentDidUpdate(prevProps, prevState) {
// console.log('update')
// const { history } = this.state;
// const prevHistory = prevState.history;
// console.log('update', history, 'prev', prevHistory)
// if (JSON.stringify(history) !== JSON.stringify(prevHistory)){
// console.log('updateDIFF')
// this._writeHistory()
// }
// }

save = (item) => {
const { id, name } = item;
let { history } = this.state;
Expand Down

0 comments on commit a255ba8

Please sign in to comment.