<commit_before><template>
  <transition-group
    name="list" tag="div"
    class="apos-notifications" :class="themeClass"
  >
    <AposNotification
      v-for="notification in notifications"
      :key="notification._id"
      :notification="notification"
      @close="dismiss"
    />
  </transition-group>
</template>

<script>
import AposThemeMixin from 'Modules/@apostrophecms/ui/mixins/AposThemeMixin';

export default {
  name: 'TheAposNotifications',
  mixins: [ AposThemeMixin ],
  data () {
    return {
      notifications: [],
      dismissed: []
    };
  },
  async mounted() {
    apos.notify = async function(message, options, interpolate) {

      if (options.dismiss === true) {
        options.dismiss = 5;
      }

      // Send it to the server, which will send it back to us via
      // the same long polling mechanism that allows it to reach
      // other tabs, and allows server-sent notifications to
      // reach us

      await apos.http.post(apos.notification.action, {
        body: {
          message,
          interpolate: interpolate || options.interpolate || {},
          type: options.type,
          icon: options.icon,
          dismiss: options.dismiss,
          buttons: options.buttons,
          localize: options.localize
        }
      });
    };

    await this.poll();
  },
  methods: {
    async dismiss(notificationId) {
      await apos.http.patch(`${apos.notification.action}/${notificationId}`, {
        body: {
          dismissed: true
        }
      });
      this.notifications = this.notifications.reduce((acc, cur) => {
        if (cur._id !== notificationId) {
          acc.push(cur);
        }
        return acc;
      }, []);
    },
    async poll() {
      try {
        if (document.visibilityState === 'hidden') {<commit_msg>removed third argument I decided not to include<commit_after><template>
  <transition-group
    name="list" tag="div"
    class="apos-notifications" :class="themeClass"
  >
    <AposNotification
      v-for="notification in notifications"
      :key="notification._id"
      :notification="notification"
      @close="dismiss"
    />
  </transition-group>
</template>

<script>
import AposThemeMixin from 'Modules/@apostrophecms/ui/mixins/AposThemeMixin';

export default {
  name: 'TheAposNotifications',
  mixins: [ AposThemeMixin ],
  data () {
    return {
      notifications: [],
      dismissed: []
    };
  },
  async mounted() {
    apos.notify = async function(message, options) {

      if (options.dismiss === true) {
        options.dismiss = 5;
      }

      // Send it to the server, which will send it back to us via
      // the same long polling mechanism that allows it to reach
      // other tabs, and allows server-sent notifications to
      // reach us

      await apos.http.post(apos.notification.action, {
        body: {
          message,
          interpolate: options.interpolate || {},
          type: options.type,
          icon: options.icon,
          dismiss: options.dismiss,
          buttons: options.buttons,
          localize: options.localize
        }
      });
    };

    await this.poll();
  },
  methods: {
    async dismiss(notificationId) {
      await apos.http.patch(`${apos.notification.action}/${notificationId}`, {
        body: {
          dismissed: true
        }
      });
      this.notifications = this.notifications.reduce((acc, cur) => {
        if (cur._id !== notificationId) {
          acc.push(cur);
        }
        return acc;
      }, []);
    },
    async poll() {
      try {
        if (document.visibilityState === 'hidden') {
{'fraction_non_alphanumeric': 0.12853970016657412, 'fraction_numerical': 0.000555247084952804, 'mean_word_length': 2.191319751992914, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3959718', 'n_tokens_mistral': 1060, 'n_tokens_neox': 1042, 'n_words': 237}