More refactoring

This commit is contained in:
Phan An 2017-05-11 09:32:32 +07:00
parent 70464a8977
commit fbeef63255
No known key found for this signature in database
GPG key ID: 4AF3D4E287BF423F
2 changed files with 5 additions and 10 deletions

View file

@ -9,11 +9,8 @@ import { ls } from '../services'
*/
export const http = {
request (method, url, data, successCb = null, errorCb = null) {
axios.request({
url,
data,
method: method.toLowerCase()
}).then(successCb).catch(errorCb)
method = method.toLowerCase()
axios.request({ url, data, method }).then(successCb).catch(errorCb)
},
get (url, successCb = null, errorCb = null) {
@ -50,9 +47,7 @@ export const http = {
// …get the token from the header or response data if exists, and save it.
const token = response.headers['Authorization'] || response.data['token']
if (token) {
ls.set('jwt-token', token)
}
token && ls.set('jwt-token', token)
return response
}, error => {

View file

@ -31,10 +31,10 @@ export const sharedStore = {
http.get('data', ({ data }) => {
assign(this.state, data)
// Don't allow downloading on mobile devices
this.state.allowDownload = this.state.allowDownload && !isMobile.any
this.state.allowDownload &= !isMobile.any
// Always disable YouTube integration on mobile.
this.state.useYouTube = this.state.useYouTube && !isMobile.phone
this.state.useYouTube &= !isMobile.phone
// If this is a new user, initialize his preferences to be an empty object.
if (!this.state.currentUser.preferences) {