Skip to content

Commit

Permalink
Remove unused localStorage config
Browse files Browse the repository at this point in the history
  • Loading branch information
deluan committed Apr 8, 2020
1 parent 089a921 commit d38f854
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 64 deletions.
108 changes: 46 additions & 62 deletions ui/src/App.js
Expand Up @@ -26,70 +26,54 @@ const i18nProvider = polyglotI18nProvider(

const history = createHashHistory()

const App = () => {
try {
const appConfig = JSON.parse(window.__APP_CONFIG__)

// This flags to the login process that it should create the first account instead
if (appConfig.firstTime) {
localStorage.setItem('initialAccountCreation', 'true')
}
localStorage.setItem('baseURL', appConfig.baseURL)
} catch (e) {}

return (
<Provider
store={createAdminStore({
authProvider,
dataProvider,
history,
customReducers: {
queue: playQueueReducer,
albumView: albumViewReducer,
theme: themeReducer
}
})}
const App = () => (
<Provider
store={createAdminStore({
authProvider,
dataProvider,
history,
customReducers: {
queue: playQueueReducer,
albumView: albumViewReducer,
theme: themeReducer
}
})}
>
<Admin
dataProvider={dataProvider}
authProvider={authProvider}
i18nProvider={i18nProvider}
customRoutes={customRoutes}
history={history}
layout={Layout}
loginPage={Login}
>
<Admin
dataProvider={dataProvider}
authProvider={authProvider}
i18nProvider={i18nProvider}
customRoutes={customRoutes}
history={history}
layout={Layout}
loginPage={Login}
>
{(permissions) => [
{(permissions) => [
<Resource name="artist" {...artist} options={{ subMenu: 'library' }} />,
<Resource name="album" {...album} options={{ subMenu: 'library' }} />,
<Resource name="song" {...song} options={{ subMenu: 'library' }} />,
<Resource name="albumSong" />,
permissions === 'admin' ? (
<Resource name="user" {...user} options={{ subMenu: 'settings' }} />
) : null,
<Resource
name="player"
{...player}
options={{ subMenu: 'settings' }}
/>,
permissions === 'admin' ? (
<Resource
name="artist"
{...artist}
options={{ subMenu: 'library' }}
/>,
<Resource name="album" {...album} options={{ subMenu: 'library' }} />,
<Resource name="song" {...song} options={{ subMenu: 'library' }} />,
<Resource name="albumSong" />,
permissions === 'admin' ? (
<Resource name="user" {...user} options={{ subMenu: 'settings' }} />
) : null,
<Resource
name="player"
{...player}
name="transcoding"
{...transcoding}
options={{ subMenu: 'settings' }}
/>,
permissions === 'admin' ? (
<Resource
name="transcoding"
{...transcoding}
options={{ subMenu: 'settings' }}
/>
) : (
<Resource name="transcoding" />
),
<Player />
]}
</Admin>
</Provider>
)
}
/>
) : (
<Resource name="transcoding" />
),
<Player />
]}
</Admin>
</Provider>
)

export default App
3 changes: 2 additions & 1 deletion ui/src/authProvider.js
Expand Up @@ -24,7 +24,6 @@ const authProvider = {
.then((response) => {
// Validate token
jwtDecode(response.token)
localStorage.removeItem('initialAccountCreation')
localStorage.setItem('token', response.token)
localStorage.setItem('name', response.name)
localStorage.setItem('username', response.username)
Expand All @@ -35,6 +34,8 @@ const authProvider = {
'subsonic-token',
generateSubsonicToken(password, salt)
)
// Avoid going to create admin dialog after logout/login without a refresh
config.firstTime = false
return response
})
.catch((error) => {
Expand Down
4 changes: 3 additions & 1 deletion ui/src/dataProvider.js
@@ -1,6 +1,7 @@
import { fetchUtils } from 'react-admin'
import jsonServerProvider from 'ra-data-json-server'
import baseUrl from './utils/baseUrl'
import config from './config'

const restUrl = '/app/api'
const customAuthorizationHeader = 'X-ND-Authorization'
Expand All @@ -19,7 +20,8 @@ const httpClient = (url, options = {}) => {
const token = response.headers.get(customAuthorizationHeader)
if (token) {
localStorage.setItem('token', token)
localStorage.removeItem('initialAccountCreation')
// Avoid going to create admin dialog after logout/login without a refresh
config.firstTime = false
}
return response
})
Expand Down

0 comments on commit d38f854

Please sign in to comment.