<commit_before>export default {
  data: () => ({
    el: 'app',
    canEnter: true,
    videoExtension: ['mkv', 'mp4', 'avi'],
    torrentExtension: ['torrent']
  }),

  computed: {
    overlay: {
      set (val) {
        this.$store.commit('overlay/show', val)
      },
      get () {
        return this.$store.state.overlay.show
      }
    }
  },

  mounted () {
    const elem = document.getElementById(this.el)

    elem.ondragenter = this.onDragEnter
    elem.ondragleave = this.onDragLeave
    elem.ondragover = this.onDragOver
    elem.ondrop = this.onDrop
  },

  methods: {
    isValidFile (ext) {
      return this.torrentExtension.includes(ext) || this.videoExtension.includes(ext)
    },
    showOverlay (bool) {
      this.overlay = bool

      if (!bool) this.canEnter = true
    },
    onDragEnter (e) {
      if (this.canEnter) {
        this.showOverlay(true)
      }
    },
    onDragLeave (e) {
      const { screenX, screenY, clientX, clientY } = e

      if (screenX === 0 && screenY === 0 && clientX === 0 && clientY === 0) {
        this.showOverlay(false)
      }
    },
    onDragOver (e) {
      e.preventDefault()
    },
    onDrop (e) {
      e.preventDefault()
      e.stopPropagation()

      const { dataTransfer: { files: [file = {}] } } = e
      const { name: fullName = '', path = '' } = file

      const fileExtension = path.split('.').slice(-1)[0]

      if (this.isValidFile(fileExtension)) {
        const name = fullName.split(' ').slice(1, -1).join(' ') // nyanparser pls

        this.$store.commit('streaming/play', {
          show: true,
          link: {
            link: path,
            name
          }
        })

        // Adding to history if video file.
        if (['mkv', 'mp4', 'avi'].includes(fullName.slice(-3))) {
          this.$store.dispatch('history/append', {
            type: 'Play',
            text: name
          })
        }
      }

      this.showOverlay(false)
    }
  }
}<commit_msg>Fix a problem where dropping a video file would be added twice to history<commit_after>export default {
  data: () => ({
    el: 'app',
    canEnter: true,
    videoExtension: ['mkv', 'mp4', 'avi'],
    torrentExtension: ['torrent']
  }),

  computed: {
    overlay: {
      set (val) {
        this.$store.commit('overlay/show', val)
      },
      get () {
        return this.$store.state.overlay.show
      }
    }
  },

  mounted () {
    const elem = document.getElementById(this.el)

    elem.ondragenter = this.onDragEnter
    elem.ondragleave = this.onDragLeave
    elem.ondragover = this.onDragOver
    elem.ondrop = this.onDrop
  },

  methods: {
    isValidFile (ext) {
      return this.torrentExtension.includes(ext) || this.videoExtension.includes(ext)
    },
    showOverlay (bool) {
      this.overlay = bool

      if (!bool) this.canEnter = true
    },
    onDragEnter (e) {
      if (this.canEnter) {
        this.showOverlay(true)
      }
    },
    onDragLeave (e) {
      const { screenX, screenY, clientX, clientY } = e

      if (screenX === 0 && screenY === 0 && clientX === 0 && clientY === 0) {
        this.showOverlay(false)
      }
    },
    onDragOver (e) {
      e.preventDefault()
    },
    onDrop (e) {
      e.preventDefault()
      e.stopPropagation()

      const { dataTransfer: { files: [file = {}] } } = e
      const { name: fullName = '', path = '' } = file

      const fileExtension = path.split('.').slice(-1)[0]

      if (this.isValidFile(fileExtension)) {
        const name = fullName.split(' ').slice(1, -1).join(' ') // nyanparser pls

        this.$store.commit('streaming/play', {
          show: true,
          link: {
            link: path,
            name
          }
        })
      }

      this.showOverlay(false)
    }
  }
}
{'fraction_non_alphanumeric': 0.1538871139510117, 'fraction_numerical': 0.005324813631522897, 'mean_word_length': 1.93515625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5799355', 'n_tokens_mistral': 1228, 'n_tokens_neox': 1212, 'n_words': 244}