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", "build:js": "rollup -c",
"watch:js": "rollup -c -w", "watch:js": "rollup -c -w",
"serve": "python ../server.py", "serve": "python ../server.py",
"serve:gui": "python ../deemix-pyweb.py --dev",
"dev": "npm-run-all --parallel serve watch:js watch:styles", "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" "build": "npm-run-all --sequential clean build:js build:styles"
}, },
"dependencies": { "dependencies": {

File diff suppressed because one or more lines are too long

View File

@ -35,10 +35,7 @@ function mountApp() {
} }
function initClient() { function initClient() {
window.clientMode = true store.dispatch('setClientMode', 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')
} }
document.addEventListener('DOMContentLoaded', startApp) document.addEventListener('DOMContentLoaded', startApp)

View File

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

View File

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

View File

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

View File

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