fix: client mode not being detected; chore: added gui dev scripts

This commit is contained in:
Roberto Tonino 2020-09-22 22:40:41 +02:00
parent 3a6577e9a8
commit 30b0881b76
7 changed files with 33 additions and 20 deletions

View File

@ -13,7 +13,9 @@
"build:js": "rollup -c",
"watch:js": "rollup -c -w",
"serve": "python ../server.py",
"serve:gui": "python ../deemix-pyweb.py --dev",
"dev": "npm-run-all --parallel serve watch:js watch:styles",
"dev:gui": "npm-run-all --parallel serve:gui watch:js watch:styles",
"build": "npm-run-all --sequential clean build:js build:styles"
},
"dependencies": {

File diff suppressed because one or more lines are too long

View File

@ -35,10 +35,7 @@ function mountApp() {
}
function initClient() {
window.clientMode = true
// document.querySelector(`#open_downloads_folder`).classList.remove('hide')
// document.querySelector(`#select_downloads_folder`).classList.remove('hide')
// document.querySelector(`#settings_btn_applogin`).classList.remove('hide')
store.dispatch('setClientMode', true)
}
document.addEventListener('DOMContentLoaded', startApp)

View File

@ -60,7 +60,7 @@
</style>
<script>
import { mapActions } from 'vuex'
import { mapActions, mapGetters } from 'vuex'
import QueueItem from '@components/downloads/QueueItem.vue'
import { socket } from '@/utils/socket'
@ -78,10 +78,15 @@ export default {
cachedTabWidth: parseInt(localStorage.getItem('downloadTabWidth')) || 300,
queue: [],
queueList: {},
queueComplete: [],
clientMode: window.clientMode
queueComplete: []
// clientMode: window.clientMode
}
},
computed: {
...mapGetters({
clientMode: 'getClientMode'
})
},
mounted() {
socket.on('startDownload', this.startDownload)
socket.on('startConversion', this.startConversion)

View File

@ -234,6 +234,9 @@ export default {
async created() {
const favoritesData = await getFavoritesData()
// TODO Change with isLoggedIn vuex getter
if (Object.entries(favoritesData).length === 0) return
this.setFavorites(favoritesData)
},
mounted() {
@ -275,7 +278,6 @@ export default {
this.spotifyPlaylists = data
},
updated_userPlaylists(data) {
console.log(data)
this.playlists = data
},
updated_userAlbums(data) {

View File

@ -678,15 +678,16 @@ export default {
slimDownloads: false,
previewVolume: window.vol,
accountNum: 0,
accounts: [],
clientMode: window.clientMode
accounts: []
// clientMode: window.clientMode
}
},
computed: {
...mapGetters({
arl: 'getARL',
user: 'getUser',
isLoggedIn: 'isLoggedIn'
isLoggedIn: 'isLoggedIn',
clientMode: 'getClientMode'
}),
needToWait() {
return Object.keys(this.getSettings).length === 0
@ -753,7 +754,7 @@ export default {
socket.on('accountChanged', this.accountChanged)
socket.on('familyAccounts', this.initAccounts)
socket.on('downloadFolderSelected', this.downloadFolderSelected)
socket.on('applogin_arl', this.setArl)
socket.on('applogin_arl', this.loggedInViaDeezer)
this.$on('hook:destroyed', () => {
socket.off('updateSettings')
@ -812,7 +813,6 @@ export default {
socket.emit('selectDownloadFolder')
},
downloadFolderSelected(folder) {
console.log(folder)
this.$set(this.settings, 'downloadLocation', folder)
},
loadSettings(data) {
@ -833,8 +833,8 @@ export default {
appLogin(e) {
socket.emit('applogin')
},
setArl(arl) {
this.dispatchARL(arl)
loggedInViaDeezer(arl) {
this.dispatchARL({ arl })
this.login()
},
changeAccount() {

View File

@ -6,7 +6,8 @@ const getDefaultState = () => {
id: null,
name: '',
picture: ''
}
},
clientMode: false
}
}
@ -43,13 +44,16 @@ const actions = {
},
setUser({ commit }, payload) {
commit('SET_USER', payload)
},
setClientMode({ commit }, payload) {
commit('SET_CLIENT_MODE', payload)
}
}
const getters = {
getARL: state => state.arl,
getUser: state => state.user,
// isLoggedIn: state => [1, 2, 3].indexOf(state.status) !== -1
getClientMode: state => state.clientMode,
isLoggedIn: state => !!state.arl
}
@ -63,6 +67,9 @@ const mutations = {
SET_USER(state, payload) {
state.user = payload
},
SET_CLIENT_MODE(state, payload) {
state.clientMode = payload
},
RESET_LOGIN(state) {
// Needed for reactivity
Object.assign(state, getDefaultState())