Skip to content
Snippets Groups Projects
Button.vue 1.33 KiB
Newer Older
  • Learn to ignore specific revisions
  • Agate's avatar
    Agate committed
      <button @click="toggleRadio" :class="['ui', 'primary', {'inverted': running}, 'icon', 'labeled', 'button']">
        <i class="ui feed icon" role="button"></i>
    
    jovuit's avatar
    jovuit committed
        <template v-if="running"><translate translate-context="*/Player/Button.Label/Short, Verb">Stop radio</translate></template>
    
        <template v-else><translate translate-context="*/Queue/Button.Label/Short, Verb">Play radio</translate></template>
    
    import lodash from '@/lodash'
    
        customRadioId: {required: false},
        type: {type: String, required: false},
    
        clientOnly: {type: Boolean, default: false},
    
        objectId: {default: null}
    
      },
      methods: {
        toggleRadio () {
          if (this.running) {
    
            this.$store.dispatch('radios/stop')
    
            this.$store.dispatch('radios/start', {
              type: this.type,
              objectId: this.objectId,
              customRadioId: this.customRadioId,
              clientOnly: this.clientOnly,
            })
    
          let state = this.$store.state.radios
          let current = state.current
          if (!state.running) {
    
            return current.type === this.type && lodash.isEqual(current.objectId, this.objectId) && current.customRadioId === this.customRadioId