diff --git a/changes/changelog.d/1060.feature b/changes/changelog.d/1060.feature
new file mode 100644
index 000000000..245a6be0c
--- /dev/null
+++ b/changes/changelog.d/1060.feature
@@ -0,0 +1 @@
+Added a new radio based on another user listenings (#1060)
diff --git a/front/src/App.vue b/front/src/App.vue
index b572b1bcd..6252198e2 100644
--- a/front/src/App.vue
+++ b/front/src/App.vue
@@ -42,6 +42,7 @@ import { WebSocketBridge } from 'django-channels'
import GlobalEvents from '@/components/utils/global-events'
import moment from 'moment'
import locales from './locales'
+import {getClientOnlyRadio} from '@/radios'
export default {
name: 'app',
@@ -138,6 +139,11 @@ export default {
id: 'sidebarPendingReviewRequestCount',
handler: this.incrementPendingReviewRequestsCountInSidebar
})
+ this.$store.commit('ui/addWebsocketEventHandler', {
+ eventName: 'Listen',
+ id: 'handleListen',
+ handler: this.handleListen
+ })
},
mounted () {
let self = this
@@ -175,6 +181,10 @@ export default {
eventName: 'user_request.created',
id: 'sidebarPendingReviewRequestCount',
})
+ this.$store.commit('ui/removeWebsocketEventHandler', {
+ eventName: 'Listen',
+ id: 'handleListen',
+ })
this.disconnect()
},
methods: {
@@ -190,6 +200,14 @@ export default {
incrementPendingReviewRequestsCountInSidebar (event) {
this.$store.commit('ui/incrementNotifications', {type: 'pendingReviewRequests', value: event.pending_count})
},
+ handleListen (event) {
+ if (this.$store.state.radios.current && this.$store.state.radios.running) {
+ let current = this.$store.state.radios.current
+ if (current.clientOnly && current.type === 'account') {
+ getClientOnlyRadio(current).handleListen(current, event, this.$store)
+ }
+ }
+ },
async fetchNodeInfo () {
let response = await axios.get('instance/nodeinfo/2.0/')
this.$store.commit('instance/nodeinfo', response.data)
diff --git a/front/src/components/audio/Player.vue b/front/src/components/audio/Player.vue
index 58f76ad07..1c720d952 100644
--- a/front/src/components/audio/Player.vue
+++ b/front/src/components/audio/Player.vue
@@ -251,6 +251,8 @@ export default {
progressInterval: null,
maxPreloaded: 3,
preloadDelay: 15,
+ listenDelay: 15,
+ listeningRecorded: null,
soundsCache: [],
soundId: null,
playTimeout: null,
@@ -477,6 +479,13 @@ export default {
this.getSound(toPreload)
this.nextTrackPreloaded = true
}
+ if (t > this.listenDelay || d - t < 30) {
+ let onlyTrack = this.$store.state.queue.tracks.length === 1
+ if (this.listeningRecorded != this.currentTrack) {
+ this.listeningRecorded = this.currentTrack
+ this.$store.dispatch('player/trackListened', this.currentTrack)
+ }
+ }
}
},
seek (step) {
diff --git a/front/src/components/audio/track/Widget.vue b/front/src/components/audio/track/Widget.vue
index 6895a8712..945db6a16 100644
--- a/front/src/components/audio/track/Widget.vue
+++ b/front/src/components/audio/track/Widget.vue
@@ -29,7 +29,7 @@