Skip to content
Snippets Groups Projects
Button.vue 1.43 KiB
Newer Older
  • Learn to ignore specific revisions
  • jovuit's avatar
    jovuit committed
      <button @click="toggleRadio" :class="['ui', 'blue', {'inverted': running}, 'icon', 'labeled', 'button']">
    
    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">Start 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
    
          }
        }
      }
    }
    </script>
    
    <!-- Add "scoped" attribute to limit CSS to this component only -->
    <style scoped>
    i {
      cursor: pointer;
    }
    </style>