summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/sidebar/components/subscriptions/sidebar_subscriptions.vue
blob: f4bae1d3dd5f45fedf7c19a55247d889d30eeac6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<script>
import Store from '../../stores/sidebar_store';
import eventHub from '../../event_hub';
import Flash from '../../../flash';
import { __ } from '../../../locale';
import subscriptions from './subscriptions.vue';

export default {
  data() {
    return {
      store: new Store(),
    };
  },
  props: {
    mediator: {
      type: Object,
      required: true,
    },
  },
  components: {
    subscriptions,
  },

  methods: {
    onToggleSubscription() {
      this.mediator.toggleSubscription()
        .catch(() => {
          Flash(__('Error occurred when toggling the notification subscription'));
        });
    },
  },

  created() {
    eventHub.$on('toggleSubscription', this.onToggleSubscription);
  },

  beforeDestroy() {
    eventHub.$off('toggleSubscription', this.onToggleSubscription);
  },
};
</script>

<template>
  <div class="block subscriptions">
    <subscriptions
      :loading="store.isFetching.subscriptions"
      :subscribed="store.subscribed" />
  </div>
</template>