diff --git a/api/pytest.ini b/api/pytest.ini
index 4ab907403..9be63d353 100644
--- a/api/pytest.ini
+++ b/api/pytest.ini
@@ -3,3 +3,4 @@ DJANGO_SETTINGS_MODULE=config.settings.test
# -- recommended but optional:
python_files = tests.py test_*.py *_tests.py
+testpatsh = tests
diff --git a/front/package.json b/front/package.json
index 5bec01602..3eb5201b2 100644
--- a/front/package.json
+++ b/front/package.json
@@ -23,7 +23,8 @@
"vue-resource": "^1.3.4",
"vue-router": "^2.3.1",
"vuedraggable": "^2.14.1",
- "vuex": "^3.0.1"
+ "vuex": "^3.0.1",
+ "vuex-persistedstate": "^2.4.2"
},
"devDependencies": {
"autoprefixer": "^6.7.2",
diff --git a/front/src/cache/index.js b/front/src/cache/index.js
deleted file mode 100644
index e039ee788..000000000
--- a/front/src/cache/index.js
+++ /dev/null
@@ -1,29 +0,0 @@
-import logger from '@/logging'
-export default {
- get (key, d) {
- let v = localStorage.getItem(key)
- if (v === null) {
- return d
- } else {
- try {
- return JSON.parse(v).value
- } catch (e) {
- logger.default.error('Removing unparsable cached value for key ' + key)
- this.remove(key)
- return d
- }
- }
- },
- set (key, value) {
- return localStorage.setItem(key, JSON.stringify({value: value}))
- },
-
- remove (key) {
- return localStorage.removeItem(key)
- },
-
- clear () {
- localStorage.clear()
- }
-
-}
diff --git a/front/src/components/Sidebar.vue b/front/src/components/Sidebar.vue
index d6a253922..a315aab19 100644
--- a/front/src/components/Sidebar.vue
+++ b/front/src/components/Sidebar.vue
@@ -62,7 +62,7 @@
{{ track.artist.name }}
-
+
@@ -94,7 +94,6 @@
import {mapState, mapActions} from 'vuex'
import Player from '@/components/audio/Player'
-import favoriteTracks from '@/favorites/tracks'
import Logo from '@/components/Logo'
import SearchBar from '@/components/audio/SearchBar'
import backend from '@/audio/backend'
@@ -112,8 +111,7 @@ export default {
},
data () {
return {
- backend: backend,
- favoriteTracks
+ backend: backend
}
},
mounted () {
diff --git a/front/src/components/audio/Player.vue b/front/src/components/audio/Player.vue
index fec74b3dc..500f4dc1d 100644
--- a/front/src/components/audio/Player.vue
+++ b/front/src/components/audio/Player.vue
@@ -5,6 +5,8 @@
v-if="currentTrack"
:key="(currentIndex, currentTrack.id)"
:is-current="true"
+ :start-time="$store.state.player.currentTime"
+ :autoplay="$store.state.player.playing"
:track="currentTrack">
@@ -127,7 +129,7 @@
@keydown.ctrl.right.prevent.exact="next"
@keydown.ctrl.down.prevent.exact="$store.commit('player/incrementVolume', -0.1)"
@keydown.ctrl.up.prevent.exact="$store.commit('player/incrementVolume', 0.1)"
- @keydown.f.prevent.exact="favoriteTracks.toggle(currentTrack.id)"
+ @keydown.f.prevent.exact="$store.dispatch('favorites/toggle', currentTrack.id)"
@keydown.l.prevent.exact="$store.commit('player/toggleLooping')"
@keydown.s.prevent.exact="shuffle"
/>
@@ -139,7 +141,6 @@
import {mapState, mapGetters, mapActions} from 'vuex'
import GlobalEvents from '@/components/utils/global-events'
-import favoriteTracks from '@/favorites/tracks'
import Track from '@/audio/track'
import AudioTrack from '@/components/audio/Track'
import TrackFavoriteIcon from '@/components/favorites/TrackFavoriteIcon'
@@ -154,8 +155,7 @@ export default {
data () {
return {
sliderVolume: this.volume,
- Track: Track,
- favoriteTracks
+ Track: Track
}
},
mounted () {
diff --git a/front/src/components/audio/SearchBar.vue b/front/src/components/audio/SearchBar.vue
index 386e24a74..9d8b39f87 100644
--- a/front/src/components/audio/SearchBar.vue
+++ b/front/src/components/audio/SearchBar.vue
@@ -18,6 +18,7 @@ const SEARCH_URL = config.API_URL + 'search?query={query}'
export default {
mounted () {
+ let self = this
jQuery(this.$el).search({
type: 'category',
minCharacters: 3,
@@ -26,7 +27,7 @@ export default {
},
apiSettings: {
beforeXHR: function (xhrObject) {
- xhrObject.setRequestHeader('Authorization', this.$store.getters['auth/header'])
+ xhrObject.setRequestHeader('Authorization', self.$store.getters['auth/header'])
return xhrObject
},
onResponse: function (initialResponse) {
diff --git a/front/src/components/audio/Track.vue b/front/src/components/audio/Track.vue
index f0e1f14fa..c8627925e 100644
--- a/front/src/components/audio/Track.vue
+++ b/front/src/components/audio/Track.vue
@@ -22,7 +22,9 @@ import url from '@/utils/url'
export default {
props: {
track: {type: Object},
- isCurrent: {type: Boolean, default: false}
+ isCurrent: {type: Boolean, default: false},
+ startTime: {type: Number, default: 0},
+ autoplay: {type: Boolean, default: false}
},
computed: {
...mapState({
@@ -57,8 +59,11 @@ export default {
},
loaded: function () {
- this.$store.commit('player/duration', this.$refs.audio.duration)
- if (this.isCurrent) {
+ if (this.isCurrent && this.autoplay) {
+ this.$store.commit('player/duration', this.$refs.audio.duration)
+ if (this.startTime) {
+ this.setCurrentTime(this.startTime)
+ }
this.$store.commit('player/playing', true)
this.$refs.audio.play()
}
@@ -72,8 +77,9 @@ export default {
if (this.looping === 1) {
this.setCurrentTime(0)
this.$refs.audio.play()
+ } else {
+ this.$store.dispatch('player/trackEnded', this.track)
}
- this.$store.dispatch('player/trackEnded', this.track)
},
setCurrentTime (t) {
if (t < 0 | t > this.duration) {
diff --git a/front/src/components/favorites/List.vue b/front/src/components/favorites/List.vue
index aef4bea93..8577e84ca 100644
--- a/front/src/components/favorites/List.vue
+++ b/front/src/components/favorites/List.vue
@@ -119,7 +119,6 @@ export default {
self.results = response.data
self.nextLink = response.data.next
self.previousLink = response.data.previous
- self.$store.commit('favorites/count', response.data.count)
self.results.results.forEach((track) => {
self.$store.commit('favorites/track', {id: track.id, value: true})
})
diff --git a/front/src/components/favorites/TrackFavoriteIcon.vue b/front/src/components/favorites/TrackFavoriteIcon.vue
index 5abc57a95..d4838ba5f 100644
--- a/front/src/components/favorites/TrackFavoriteIcon.vue
+++ b/front/src/components/favorites/TrackFavoriteIcon.vue
@@ -1,5 +1,5 @@
-
|