From cd63646f391030d083c6ce6de250dcbf177d1e9b Mon Sep 17 00:00:00 2001 From: Eliot Berriot Date: Wed, 25 Mar 2020 22:24:31 +0100 Subject: [PATCH] Fix #1060: Added a new radio based on another user listenings --- changes/changelog.d/1060.feature | 1 + front/src/App.vue | 18 ++++++++ front/src/components/audio/track/Widget.vue | 2 +- front/src/components/radios/Button.vue | 11 ++++- front/src/radios.js | 51 +++++++++++++++++++++ front/src/store/radios.js | 20 ++++++-- front/src/store/ui.js | 1 + front/src/views/auth/ProfileBase.vue | 7 +++ front/tests/unit/specs/store/player.spec.js | 2 - front/tests/unit/specs/store/radios.spec.js | 1 + 10 files changed, 106 insertions(+), 8 deletions(-) create mode 100644 changes/changelog.d/1060.feature create mode 100644 front/src/radios.js 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/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 @@
- @{{ object.user.username }} + @{{ object.user.username }}
diff --git a/front/src/components/radios/Button.vue b/front/src/components/radios/Button.vue index f335a6596..7e1ff40c5 100644 --- a/front/src/components/radios/Button.vue +++ b/front/src/components/radios/Button.vue @@ -8,10 +8,12 @@