From f9e83203b53057e2fbcb457e9c04ba4aa2c36e68 Mon Sep 17 00:00:00 2001 From: Kevin Doran Date: Fri, 10 Apr 2020 10:06:51 +0100 Subject: [PATCH] fix: remove weird cache --- app/app.js | 68 +++++++++++++-------------- app/components/Login.js | 2 +- app/containers/SetupCouchContainer.js | 10 ++-- app/utils/cache.js | 7 --- 4 files changed, 38 insertions(+), 49 deletions(-) delete mode 100644 app/utils/cache.js diff --git a/app/app.js b/app/app.js index 1d29bf6..526ca9b 100644 --- a/app/app.js +++ b/app/app.js @@ -14,7 +14,6 @@ import Nav from './components/Nav' import Login from './components/Login' import Loading from './components/Loading' import withParams from './containers/withParams' -import cache from './utils/cache' import { parseUrl } from './utils/utils' import fetcher from 'utils/fetcher' @@ -24,11 +23,11 @@ import 'app-tags.css' const Databases = withParams(DatabasesContainer) const LIMIT = 100 -class UserRoutes extends Component { +class CouchRoutes extends Component { constructor (props) { super(props) this.state = { - authenticated: !!cache.userCtx.name, + userCtx: null, loading: true, couchUrl: parseUrl(props.match.params.couch), dbs: null @@ -45,47 +44,44 @@ class UserRoutes extends Component { return } - this.onAuthenticated(userCtx) + this.onUser(userCtx) } // TODO: this cache object was never used much - onAuthenticated = async (userCtx) => { + onUser = async (userCtx) => { const { couchUrl } = this.state - Object.assign(cache.userCtx, userCtx) const dbs = await fetcher.get(`${couchUrl}_all_dbs`, { limit: LIMIT }) - this.setState({ loading: false, dbs, authenticated: true }) + this.setState({ loading: false, dbs, userCtx }) } render () { - const { authenticated, loading, couchUrl, dbs } = this.state - if (loading) { - return - } - if (!authenticated) { - return - } else { - return ( -
-
- - - - - - - - - - - - - } /> - -
- (