From 8c948421295b9f369396848b47003a828d98537c Mon Sep 17 00:00:00 2001 From: yadpe Date: Fri, 9 Aug 2019 21:01:42 +0200 Subject: [PATCH 1/7] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1702bfa3..12ec0621 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Beatconnect client This App gives you access to all the beatmaps mirrored on [Beatconnect](https://beatconnect.io). You can downloads multiple beatmaps that will be automaticaly imported into osu!
-Plus, you can launch an IRC bot from the app that will make all [available commands](./doc/commands.md) usable to peoples pming you and from all the matches chats that the bot is connected to. (how to connect docs soon..) +Plus, you can launch an IRC bot from the app that will make all [available commands](./docs/commands.md) usable to peoples pming you and from all the matches chats that the bot is connected to. (how to connect docs soon..) From 9f71a484f97946d8cb8e7baba8f14fb9cad0aa51 Mon Sep 17 00:00:00 2001 From: yadpe Date: Sat, 10 Aug 2019 01:45:07 +0200 Subject: [PATCH 2/7] autoUpdater setup --- .gitignore | 1 + package-lock.json | 95 +++++++++++++++++++++++++++++++++++++++------- package.json | 12 +++++- public/electron.js | 15 ++++---- 4 files changed, 101 insertions(+), 22 deletions(-) diff --git a/.gitignore b/.gitignore index c973abe6..3bc0b0fa 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ conf.json src/Bot/conf.js log.txt \.idea/ +secrets diff --git a/package-lock.json b/package-lock.json index df23b47e..b2414ccd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1428,6 +1428,11 @@ "resolved": "https://registry.npmjs.org/@types/q/-/q-1.5.2.tgz", "integrity": "sha512-ce5d3q03Ex0sy4R14722Rmt6MT07Ua+k4FwDfdcToYJcMKNtRVQvJ6JCAPdAmAnbRb6CsX6aYb9m96NGod9uTw==" }, + "@types/semver": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-6.0.1.tgz", + "integrity": "sha512-ffCdcrEE5h8DqVxinQjo+2d1q+FV5z7iNtPofw3JsrltSoSVlOGaW0rY8XxtO9XukdTn8TaCGWmk2VFGhI70mg==" + }, "@types/stack-utils": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-1.0.1.tgz", @@ -4575,6 +4580,47 @@ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.183.tgz", "integrity": "sha512-WbKCYs7yAFOfpuoa2pK5kbOngriUtlPC+8mcQW5L/686wv04w7hYXfw5ScDrsl9kixFw1SPsALEob5V/gtlDxw==" }, + "electron-updater": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/electron-updater/-/electron-updater-4.1.2.tgz", + "integrity": "sha512-4Sk8IW0LfOilDz+WAB/gEDmX7+FUFRbKHGN1zGjehPilnd6H9cmjgBHK6Xzq/FLq/uOHGJ6GX/9tsF+jr7CvnA==", + "requires": { + "@types/semver": "^6.0.1", + "builder-util-runtime": "8.3.0", + "fs-extra": "^8.1.0", + "js-yaml": "^3.13.1", + "lazy-val": "^1.0.4", + "lodash.isequal": "^4.5.0", + "pako": "^1.0.10", + "semver": "^6.2.0" + }, + "dependencies": { + "builder-util-runtime": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/builder-util-runtime/-/builder-util-runtime-8.3.0.tgz", + "integrity": "sha512-CSOdsYqf4RXIHh1HANPbrZHlZ9JQJXSuDDloblZPcWQVN62inyYoTQuSmY3KrgefME2Sv3Kn2MxHvbGQHRf8Iw==", + "requires": { + "debug": "^4.1.1", + "sax": "^1.2.4" + } + }, + "fs-extra": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" + } + } + }, "elliptic": { "version": "6.5.0", "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.0.tgz", @@ -5781,7 +5827,8 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true + "bundled": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -5799,11 +5846,13 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true + "bundled": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -5816,15 +5865,18 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "concat-map": { "version": "0.0.1", - "bundled": true + "bundled": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -5927,7 +5979,8 @@ }, "inherits": { "version": "2.0.3", - "bundled": true + "bundled": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -5937,6 +5990,7 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -5949,17 +6003,20 @@ "minimatch": { "version": "3.0.4", "bundled": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true + "bundled": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -5976,6 +6033,7 @@ "mkdirp": { "version": "0.5.1", "bundled": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -6048,7 +6106,8 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true + "bundled": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -6058,6 +6117,7 @@ "once": { "version": "1.4.0", "bundled": true, + "optional": true, "requires": { "wrappy": "1" } @@ -6133,7 +6193,8 @@ }, "safe-buffer": { "version": "5.1.2", - "bundled": true + "bundled": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -6163,6 +6224,7 @@ "string-width": { "version": "1.0.2", "bundled": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -6180,6 +6242,7 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -6218,11 +6281,13 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true + "bundled": true, + "optional": true }, "yallist": { "version": "3.0.3", - "bundled": true + "bundled": true, + "optional": true } } }, @@ -8272,8 +8337,7 @@ "lazy-val": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/lazy-val/-/lazy-val-1.0.4.tgz", - "integrity": "sha512-u93kb2fPbIrfzBuLjZE+w+fJbUUMhNDXxNmMfaqNgpfQf1CO5ZSe2LfsnBqVAk7i/2NF48OSoRj+Xe2VT+lE8Q==", - "dev": true + "integrity": "sha512-u93kb2fPbIrfzBuLjZE+w+fJbUUMhNDXxNmMfaqNgpfQf1CO5ZSe2LfsnBqVAk7i/2NF48OSoRj+Xe2VT+lE8Q==" }, "lcid": { "version": "2.0.0", @@ -8403,6 +8467,11 @@ "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", "integrity": "sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=" }, + "lodash.isequal": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", + "integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA=" + }, "lodash.memoize": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", diff --git a/package.json b/package.json index cc826388..49fbbb7f 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "dist": "npm run build && npx npx electron-builder --win --linux --ia32", "dist-win": "npm run build && npx electron-builder build --win --ia32", "dist-linux": "npm run build && npx electron-builder build --linux --ia32", - "gh-publish": "npm run build && npx electron-builder build -p onTag", + "gh-publish": "npm run build && npx electron-builder build --win --linux --ia32 -p always", "electron-dev": "set ELECTRON_START_URL=http://localhost:3000 && electron ." }, "eslintConfig": { @@ -33,6 +33,13 @@ }, "build": { "appId": "io.beatconnect.client", + "publish": [ + { + "provider": "github", + "owner": "yadPe", + "repo": "beatconnect_client" + } + ], "files": [ "build/**/*", "node_modules/**/*" @@ -89,6 +96,7 @@ "electron-download-manager": "^2.1.2", "electron-is-dev": "^1.1.0", "electron-log": "^3.0.7", + "electron-updater": "^4.1.2", "eslint": "^5.16.0", "eslint-config-react-app": "^4.0.1", "eslint-loader": "2.1.2", @@ -209,4 +217,4 @@ "react-app" ] } -} +} \ No newline at end of file diff --git a/public/electron.js b/public/electron.js index 15111ad4..a8d5bb6e 100644 --- a/public/electron.js +++ b/public/electron.js @@ -1,16 +1,17 @@ -const electron = require('electron'); -const { app } = electron; +const { app } = require('electron'); +// const { app } = electron; const Window = require('./Window'); const path = require('path') const url = require('url') const isDev = require('electron-is-dev'); -require('update-electron-app')({ - repo: 'yadPe/beatconnect_client.git', - logger: require('electron-log') -}) - +const { autoUpdater } = require('electron-updater'); const DownloadManager = require("electron-download-manager"); +// require('update-electron-app')({ +// repo: 'yadPe/beatconnect_client.git', +// logger: require('electron-log') +// }) +autoUpdater.checkForUpdatesAndNotify() DownloadManager.register({ downloadFolder: app.getPath("downloads") + "/beatconnect" }); From 63eff2e106849500c1f38240eac52c149c5da5c1 Mon Sep 17 00:00:00 2001 From: yadpe Date: Sat, 10 Aug 2019 02:21:28 +0200 Subject: [PATCH 3/7] display version in settings --- package.json | 4 ++-- src/App/components/Settings/index.js | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 49fbbb7f..0d715d28 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "beatconnect_client", "productName": "Beatconnect Client", - "version": "0.1.3", + "version": "0.1.4", "description": "Beatconnect power for osu irc", "author": "yadpe ", "license": "GPL-3.0", @@ -15,7 +15,7 @@ "dist": "npm run build && npx npx electron-builder --win --linux --ia32", "dist-win": "npm run build && npx electron-builder build --win --ia32", "dist-linux": "npm run build && npx electron-builder build --linux --ia32", - "gh-publish": "npm run build && npx electron-builder build --win --linux --ia32 -p always", + "gh-publish": "npm run build && npx electron-builder build --win --ia32 -p always", "electron-dev": "set ELECTRON_START_URL=http://localhost:3000 && electron ." }, "eslintConfig": { diff --git a/src/App/components/Settings/index.js b/src/App/components/Settings/index.js index 0960c369..8b1bccb8 100644 --- a/src/App/components/Settings/index.js +++ b/src/App/components/Settings/index.js @@ -1,5 +1,6 @@ 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'; @@ -18,6 +19,7 @@ const Settings = ({ userPreferences, theme }) => { updateVolume(e.target.value)} /> +
{`Beatconnect client v${remote.app.getVersion()}`}
); } From 38507a18cbf2eb5d250090512886aff354df27ec Mon Sep 17 00:00:00 2001 From: yadpe Date: Sat, 10 Aug 2019 02:24:02 +0200 Subject: [PATCH 4/7] display autoUpdate erro in dialog --- package.json | 2 +- public/electron.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 0d715d28..ac52996e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "beatconnect_client", "productName": "Beatconnect Client", - "version": "0.1.4", + "version": "0.1.5", "description": "Beatconnect power for osu irc", "author": "yadpe ", "license": "GPL-3.0", diff --git a/public/electron.js b/public/electron.js index a8d5bb6e..283b1833 100644 --- a/public/electron.js +++ b/public/electron.js @@ -1,4 +1,4 @@ -const { app } = require('electron'); +const { app, dialog } = require('electron'); // const { app } = electron; const Window = require('./Window'); const path = require('path') @@ -11,6 +11,9 @@ const DownloadManager = require("electron-download-manager"); // logger: require('electron-log') // }) +autoUpdater.on('error', (error) => { + dialog.showErrorBox('Error: ', error == null ? "unknown" : (error.stack || error).toString()) +}) autoUpdater.checkForUpdatesAndNotify() DownloadManager.register({ downloadFolder: app.getPath("downloads") + "/beatconnect" From 75ccaace505c99748cf0e8576d0fe1a989329e78 Mon Sep 17 00:00:00 2001 From: yadpe Date: Sat, 10 Aug 2019 14:53:54 +0200 Subject: [PATCH 5/7] Darker theme --- src/App/components/Settings/Theme.js | 13 ++++++++++++- src/App/components/Settings/index.js | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/App/components/Settings/Theme.js b/src/App/components/Settings/Theme.js index 11d30238..cc1d77b4 100644 --- a/src/App/components/Settings/Theme.js +++ b/src/App/components/Settings/Theme.js @@ -1,10 +1,21 @@ import React from 'react' +/* TODO +* make a dedicated theme provider +* store theme variant in userPreferences +* add custom themes +*/ + const Theme = () => { return (

Theme

- +

Darker

+ e.target.checked ? document.body.style.backgroundColor = 'transparent' : document.body.style.backgroundColor= '#2a2a2a'} + />
); } diff --git a/src/App/components/Settings/index.js b/src/App/components/Settings/index.js index 8b1bccb8..57e3f82f 100644 --- a/src/App/components/Settings/index.js +++ b/src/App/components/Settings/index.js @@ -8,6 +8,7 @@ import { Button } from 'react-desktop/windows'; import ConfLoader from './ConfLoader'; import { updateVolume } from './actions'; import Configuration from './Configuration'; +import Theme from './Theme'; const Settings = ({ userPreferences, theme }) => { useEffect(() => { @@ -19,6 +20,7 @@ const Settings = ({ userPreferences, theme }) => { updateVolume(e.target.value)} /> +
{`Beatconnect client v${remote.app.getVersion()}`}
); From 229ff4890c59224fd0d53cf11be886e4145a1c4b Mon Sep 17 00:00:00 2001 From: yadpe Date: Sat, 10 Aug 2019 15:05:28 +0200 Subject: [PATCH 6/7] #11 auto-update ready --- package.json | 8 +++----- public/Window.js | 19 +++++-------------- public/electron.js | 26 ++++++++------------------ 3 files changed, 16 insertions(+), 37 deletions(-) diff --git a/package.json b/package.json index ac52996e..2973e983 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "beatconnect_client", "productName": "Beatconnect Client", - "version": "0.1.5", + "version": "0.1.4", "description": "Beatconnect power for osu irc", "author": "yadpe ", "license": "GPL-3.0", @@ -11,11 +11,12 @@ "start": "node scripts/start.js", "build": "node scripts/build.js", "test": "node scripts/test.js", + "lint": "eslint src/App/**", "go": "electron .", "dist": "npm run build && npx npx electron-builder --win --linux --ia32", "dist-win": "npm run build && npx electron-builder build --win --ia32", "dist-linux": "npm run build && npx electron-builder build --linux --ia32", - "gh-publish": "npm run build && npx electron-builder build --win --ia32 -p always", + "gh-publish": "npm run build && npx electron-builder build --win --linux --ia32 -p always", "electron-dev": "set ELECTRON_START_URL=http://localhost:3000 && electron ." }, "eslintConfig": { @@ -105,8 +106,6 @@ "eslint-plugin-jsx-a11y": "6.2.1", "eslint-plugin-react": "7.12.4", "eslint-plugin-react-hooks": "^1.5.0", - "express": "^4.17.1", - "express-prettify": "^0.1.1", "file-loader": "3.0.1", "fs-extra": "^7.0.1", "html-webpack-plugin": "4.0.0-beta.5", @@ -151,7 +150,6 @@ }, "devDependencies": { "electron-builder": "^20.44.4", - "nodemon": "^1.19.1", "electron": "^5.0.5", "typescript": "^3.5.3" }, diff --git a/public/Window.js b/public/Window.js index ccf8523d..d6d74f32 100644 --- a/public/Window.js +++ b/public/Window.js @@ -10,28 +10,19 @@ const defaultProps = { minWidth: 850, show: false, darkTheme: true, - // frame: false frame: process.env.ELECTRON_START_URL ? true : false -} +}; class Window extends BrowserWindow { constructor ({ url, ...windowSettings }) { // calls new BrowserWindow with these props - super({ ...defaultProps, ...windowSettings }) - - // load the html and open devtools - //this.loadFile(file) - this.loadURL(url) - // this.webContents.openDevTools() - - // gracefully show when ready to prevent flickering + super({ ...defaultProps, ...windowSettings }); - // this.on('will-move', (e) => this.setOpacity(0.75)) - // this.on('moved', () => this.setOpacity(windowSettings.opacity || 1)) + this.loadURL(url); this.once('ready-to-show', () => { - this.show() - }) + this.show(); + }); } } diff --git a/public/electron.js b/public/electron.js index 283b1833..98efba64 100644 --- a/public/electron.js +++ b/public/electron.js @@ -1,31 +1,21 @@ -const { app, dialog } = require('electron'); -// const { app } = electron; -const Window = require('./Window'); -const path = require('path') -const url = require('url') +const { app } = require('electron'); +const log = require('electron-log'); const isDev = require('electron-is-dev'); const { autoUpdater } = require('electron-updater'); const DownloadManager = require("electron-download-manager"); -// require('update-electron-app')({ -// repo: 'yadPe/beatconnect_client.git', -// logger: require('electron-log') -// }) +const Window = require('./Window'); +const path = require('path') +const url = require('url') + autoUpdater.on('error', (error) => { - dialog.showErrorBox('Error: ', error == null ? "unknown" : (error.stack || error).toString()) -}) + log.warn(`Error: \n ${error == null ? "unknown" : (error.stack || error).toString()}`); +}); autoUpdater.checkForUpdatesAndNotify() DownloadManager.register({ downloadFolder: app.getPath("downloads") + "/beatconnect" }); - -// https://codeburst.io/build-a-todo-app-with-electron-d6c61f58b55a -// https://electronjs.org/docs/api/browser-window -// https://www.freecodecamp.org/news/building-an-electron-application-with-create-react-app-97945861647c/ -// https://medium.com/@brockhoff/using-electron-with-react-the-basics-e93f9761f86f - - const main = () => { let mainWindow = null; console.log('readee') From a255ba842e98f361a71df0cc5039f14c6c8d936f Mon Sep 17 00:00:00 2001 From: YadPe Date: Sat, 10 Aug 2019 15:29:04 +0200 Subject: [PATCH 7/7] linting --- src/App/components/Browse/index.js | 3 +-- src/App/components/Downloads/DownloadedItems.js | 2 +- src/App/components/Downloads/DownloadsInQueue.js | 2 +- src/App/components/Downloads/index.js | 4 +--- src/App/components/Matchs/AddMatch.js | 1 - .../components/Matchs/MatchDetails/ControlsBar.js | 4 +--- src/App/components/Matchs/MatchDetails/index.js | 2 +- src/App/components/Matchs/index.js | 2 +- src/App/components/Nav.js | 2 +- src/App/components/Settings/index.js | 2 -- src/App/components/Start/index.js | 3 ++- src/App/components/common/Beatmap/Cover.js | 1 + .../common/Beatmap/DownloadBeatmapBtn.js | 2 +- .../common/Beatmap/PreviewBeatmapBtn.js | 2 +- src/App/components/common/Beatmap/index.js | 15 +++++---------- src/App/utils/renderIcons.js | 2 ++ src/App/utils/timeSince.js | 2 +- src/Bot/BeatconnectApi.js | 2 +- src/Bot/Bot.js | 10 +++++----- src/Bot/msg/mpSettings.js | 1 + src/Providers/HistoryProvider.js | 15 ++------------- 21 files changed, 30 insertions(+), 49 deletions(-) diff --git a/src/App/components/Browse/index.js b/src/App/components/Browse/index.js index eab98359..c7f9a977 100644 --- a/src/App/components/Browse/index.js +++ b/src/App/components/Browse/index.js @@ -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'; diff --git a/src/App/components/Downloads/DownloadedItems.js b/src/App/components/Downloads/DownloadedItems.js index 51c903ab..5978ad9a 100644 --- a/src/App/components/Downloads/DownloadedItems.js +++ b/src/App/components/Downloads/DownloadedItems.js @@ -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'; diff --git a/src/App/components/Downloads/DownloadsInQueue.js b/src/App/components/Downloads/DownloadsInQueue.js index 0fe63e1d..0fcee7ea 100644 --- a/src/App/components/Downloads/DownloadsInQueue.js +++ b/src/App/components/Downloads/DownloadsInQueue.js @@ -1,4 +1,4 @@ -import React, { useContext, useCallback } from 'react'; +import React, { useContext } from 'react'; import DownloadsItem from './Item'; import { DownloadQueueContext } from '../../../Providers/DownloadQueueProvider' diff --git a/src/App/components/Downloads/index.js b/src/App/components/Downloads/index.js index 6185e294..851d03db 100644 --- a/src/App/components/Downloads/index.js +++ b/src/App/components/Downloads/index.js @@ -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 ( diff --git a/src/App/components/Matchs/AddMatch.js b/src/App/components/Matchs/AddMatch.js index 7ed74cdd..d1cf8b2b 100644 --- a/src/App/components/Matchs/AddMatch.js +++ b/src/App/components/Matchs/AddMatch.js @@ -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 ( { push color={theme.color} onClick={match.toggleAutoBeat} - // hidden={!beatmap.title} > {`AutoBeat: ${match.autoBeat ? ' on' : 'off'}`} diff --git a/src/App/components/Matchs/MatchDetails/index.js b/src/App/components/Matchs/MatchDetails/index.js index 977145a7..5ebf691d 100644 --- a/src/App/components/Matchs/MatchDetails/index.js +++ b/src/App/components/Matchs/MatchDetails/index.js @@ -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'; diff --git a/src/App/components/Matchs/index.js b/src/App/components/Matchs/index.js index 84703afe..17c200ed 100644 --- a/src/App/components/Matchs/index.js +++ b/src/App/components/Matchs/index.js @@ -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' diff --git a/src/App/components/Nav.js b/src/App/components/Nav.js index d37c9a2b..c373b52f 100644 --- a/src/App/components/Nav.js +++ b/src/App/components/Nav.js @@ -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' diff --git a/src/App/components/Settings/index.js b/src/App/components/Settings/index.js index 57e3f82f..d86b6776 100644 --- a/src/App/components/Settings/index.js +++ b/src/App/components/Settings/index.js @@ -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'; diff --git a/src/App/components/Start/index.js b/src/App/components/Start/index.js index d768e265..fc4bc56c 100644 --- a/src/App/components/Start/index.js +++ b/src/App/components/Start/index.js @@ -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 }) => { @@ -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 ( diff --git a/src/App/components/common/Beatmap/Cover.js b/src/App/components/common/Beatmap/Cover.js index 5c203e14..6e673019 100644 --- a/src/App/components/common/Beatmap/Cover.js +++ b/src/App/components/common/Beatmap/Cover.js @@ -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 = { diff --git a/src/App/components/common/Beatmap/DownloadBeatmapBtn.js b/src/App/components/common/Beatmap/DownloadBeatmapBtn.js index a9f47581..c1a66f4b 100644 --- a/src/App/components/common/Beatmap/DownloadBeatmapBtn.js +++ b/src/App/components/common/Beatmap/DownloadBeatmapBtn.js @@ -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'; diff --git a/src/App/components/common/Beatmap/PreviewBeatmapBtn.js b/src/App/components/common/Beatmap/PreviewBeatmapBtn.js index 07c61da0..d55f15d3 100644 --- a/src/App/components/common/Beatmap/PreviewBeatmapBtn.js +++ b/src/App/components/common/Beatmap/PreviewBeatmapBtn.js @@ -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'; diff --git a/src/App/components/common/Beatmap/index.js b/src/App/components/common/Beatmap/index.js index 5bf6cb8d..80cc0211 100644 --- a/src/App/components/common/Beatmap/index.js +++ b/src/App/components/common/Beatmap/index.js @@ -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' @@ -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%', @@ -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(() => { diff --git a/src/App/utils/renderIcons.js b/src/App/utils/renderIcons.js index b4f1fd01..124aabf7 100644 --- a/src/App/utils/renderIcons.js +++ b/src/App/utils/renderIcons.js @@ -176,5 +176,7 @@ export default function(name, style) { L311.1,311.1z"/> ); + default: + return null } } \ No newline at end of file diff --git a/src/App/utils/timeSince.js b/src/App/utils/timeSince.js index 0318f4e1..f8c6f193 100644 --- a/src/App/utils/timeSince.js +++ b/src/App/utils/timeSince.js @@ -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; } } \ No newline at end of file diff --git a/src/Bot/BeatconnectApi.js b/src/Bot/BeatconnectApi.js index a5276d76..dc9b7f6f 100644 --- a/src/Bot/BeatconnectApi.js +++ b/src/Bot/BeatconnectApi.js @@ -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}]`; diff --git a/src/Bot/Bot.js b/src/Bot/Bot.js index 2b466842..f332b4f2 100644 --- a/src/Bot/Bot.js +++ b/src/Bot/Bot.js @@ -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); @@ -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 @@ -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(); @@ -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; diff --git a/src/Bot/msg/mpSettings.js b/src/Bot/msg/mpSettings.js index 8a0d1170..ee4365d9 100644 --- a/src/Bot/msg/mpSettings.js +++ b/src/Bot/msg/mpSettings.js @@ -1,3 +1,4 @@ +/* eslint-disable array-callback-return */ import store from "../../store"; export default function(msg) { diff --git a/src/Providers/HistoryProvider.js b/src/Providers/HistoryProvider.js index 1d16b872..8b352570 100644 --- a/src/Providers/HistoryProvider.js +++ b/src/Providers/HistoryProvider.js @@ -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(); @@ -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;