<commit_before>import datastore from '@/store'
import router from '@/router'

document.addEventListener('deviceready', onDeviceReady, false)

const devicereadyTimeout = setTimeout(() => {
  console.error('deviceready not fired within 5 seconds, is cordova.js loaded? FCM will not work otherwise.')
}, 5000)

async function onDeviceReady () {
  clearTimeout(devicereadyTimeout)
  const { FCMPlugin } = window
  if (FCMPlugin) {
    receiveFCMToken(await FCMPlugin.getToken())
    FCMPlugin.onTokenRefresh(receiveFCMToken)
    FCMPlugin.onNotification(receiveNotification)
  }
  else {
    console.error('window.FCMPlugin is not available, push notifications will not work')
  }
}

function receiveNotification (data) {
  if (!data.wasTapped) return
  // Notification was received on device tray and tapped by the user
  const path = data.karrot_route
  if (path) {
    const pendingRoute = datastore.state.routeMeta.next
    if (pendingRoute && pendingRoute.path === path) return
    router.push(path).catch(() => {})
  }
}

function receiveFCMToken (token) {
  datastore.commit('fcm/setToken', token)
}
<commit_msg>fix wrong FCMPlugin name<commit_after>import datastore from '@/store'
import router from '@/router'

document.addEventListener('deviceready', onDeviceReady, false)

const devicereadyTimeout = setTimeout(() => {
  console.error('deviceready not fired within 5 seconds, is cordova.js loaded? FCM will not work otherwise.')
}, 5000)

async function onDeviceReady () {
  clearTimeout(devicereadyTimeout)
  const { FCM } = window
  if (FCM) {
    receiveFCMToken(await FCM.getToken())
    FCM.onTokenRefresh(receiveFCMToken)
    FCM.onNotification(receiveNotification)
  }
  else {
    console.error('window.FCM is not available, push notifications will not work')
  }
}

function receiveNotification (data) {
  if (!data.wasTapped) return
  // Notification was received on device tray and tapped by the user
  const path = data.karrot_route
  if (path) {
    const pendingRoute = datastore.state.routeMeta.next
    if (pendingRoute && pendingRoute.path === path) return
    router.push(path).catch(() => {})
  }
}

function receiveFCMToken (token) {
  datastore.commit('fcm/setToken', token)
}

{'fraction_non_alphanumeric': 0.10975056689342404, 'fraction_numerical': 0.0045351473922902496, 'mean_word_length': 4.542713567839196, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1659172', 'n_tokens_mistral': 695, 'n_tokens_neox': 657, 'n_words': 179}