From 7ee91824a0e07d6557efebc5a8880bb228550ea6 Mon Sep 17 00:00:00 2001 From: luin Date: Sat, 18 Feb 2017 12:17:28 +0800 Subject: [PATCH] fix: detect database number for Heroku Redis Close #55, #52 --- README.md | 10 ++++++++ .../main/Main/Database/KeyBrowser/Footer.jsx | 23 ++++++++----------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 2e7db190..2629a4ba 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,16 @@ $ npm install $ npm run deploy ``` +## Connect to Heroku +Medis can connect to Heroku Redis addon to manage your data. You just need to call `heroku redis:credentials --app APP` to get your redis credential: + +```shell +$ heroku redis:credentials --app YOUR_APP +redis://x:PASSWORD@HOST:PORT +``` + +And then input `HOST`, `PORT` and `PASSWORD` to the connection tab. + ## I Love This. How do I Help? * Simply star this repository :-) diff --git a/client/components/main/Main/Database/KeyBrowser/Footer.jsx b/client/components/main/Main/Database/KeyBrowser/Footer.jsx index 60f9c929..d011445f 100644 --- a/client/components/main/Main/Database/KeyBrowser/Footer.jsx +++ b/client/components/main/Main/Database/KeyBrowser/Footer.jsx @@ -22,19 +22,16 @@ class Footer extends React.Component { updateDBCount() { this.props.redis.config('get', 'databases', (err, res) => { - if (!err) { - if (res[1]) { - this.setState({ databases: Number(res[1]) }); - } else { - const redis = this.props.redis.duplicate(); - const select = redis.select.bind(redis); - this.guessDatabaseNumber(select, 15).then((count) => { - console.log('===', count) - return typeof count === 'number' ? count : this.guessDatabaseNumber(select, 1, 0); - }).then((count) => { - this.setState({ databases: count + 1 }); - }); - } + if (!err && res[1]) { + this.setState({ databases: Number(res[1]) }); + } else { + const redis = this.props.redis.duplicate(); + const select = redis.select.bind(redis); + this.guessDatabaseNumber(select, 15).then((count) => { + return typeof count === 'number' ? count : this.guessDatabaseNumber(select, 1, 0); + }).then((count) => { + this.setState({ databases: count + 1 }); + }); } }); }