<commit_before>import { Platform } from 'quasar'

import { createRouteRedirect } from '@/store/helpers'
import pickupsAPI from '@/services/api/pickups'

function initialState () {
  return {
    pickupId: null,
    conversationId: null,
  }
}

export default {
  namespaced: true,
  state: initialState(),
  getters: {
    isActive: state => {
      return !!state.pickupId
    },
    pickup: (state, getters, rootState, rootGetters) => {
      if (!state.pickupId) return
      return rootGetters['pickups/get'](state.pickupId)
    },
    conversation: (state, getters, rootState, rootGetters) => {
      if (!state.conversationId) return
      return rootGetters['conversations/get'](state.conversationId)
    },
  },
  actions: {
    async routeEnter ({ dispatch }, { groupId, storeId, pickupId, routeTo }) {
      dispatch('selectPickup', { pickupId })
      if (!Platform.is.mobile) {
        // On desktop we don't have a pickup detail page, we go to the store page, and have a sidebar open
        throw createRouteRedirect({ name: 'store', params: { groupId, storeId }, query: routeTo.query })
      }
    },
    routeLeave ({ dispatch }) {
      if (Platform.is.mobile) dispatch('clear')
    },
    async selectPickup ({ commit, dispatch }, { pickupId }) {
      const [conversation] = await Promise.all([
        pickupsAPI.conversation(pickupId),
        dispatch('pickups/fetch', pickupId, { root: true }),
      ])
      dispatch('conversations/fetchConversation', conversation.id, { root: true })
      dispatch('conversations/fetch', conversation.id, { root: true }) // gets the messages
      commit('setPickupId', pickupId)
      commit('setConversationId', conversation.id)
    },
    clear ({ commit }) {
      commit('clear')
    },
  },
  mutations: {
    setPickupId (state, pickupId) {
      state.pickupId = pickupId<commit_msg>wait until data is fetched before resolving routeEnter<commit_after>import { Platform } from 'quasar'

import { createRouteRedirect } from '@/store/helpers'
import pickupsAPI from '@/services/api/pickups'

function initialState () {
  return {
    pickupId: null,
    conversationId: null,
  }
}

export default {
  namespaced: true,
  state: initialState(),
  getters: {
    isActive: state => {
      return !!state.pickupId
    },
    pickup: (state, getters, rootState, rootGetters) => {
      if (!state.pickupId) return
      return rootGetters['pickups/get'](state.pickupId)
    },
    conversation: (state, getters, rootState, rootGetters) => {
      if (!state.conversationId) return
      return rootGetters['conversations/get'](state.conversationId)
    },
  },
  actions: {
    async routeEnter ({ dispatch }, { groupId, storeId, pickupId, routeTo }) {
      await dispatch('selectPickup', { pickupId })
      if (!Platform.is.mobile) {
        // On desktop we don't have a pickup detail page, we go to the store page, and have a sidebar open
        throw createRouteRedirect({ name: 'store', params: { groupId, storeId }, query: routeTo.query })
      }
    },
    routeLeave ({ dispatch }) {
      if (Platform.is.mobile) dispatch('clear')
    },
    async selectPickup ({ commit, dispatch }, { pickupId }) {
      const [conversation] = await Promise.all([
        pickupsAPI.conversation(pickupId),
        dispatch('pickups/maybeFetch', pickupId, { root: true }),
      ])
      await Promise.all([
        dispatch('conversations/fetchConversation', conversation.id, { root: true }),
        dispatch('conversations/fetch', conversation.id, { root: true }), // gets the messages
      ])
      commit('setPickupId', pickupId)
      commit('setConversationId', conversation.id)
    },
    clear ({ commit }) {
      commit('clear')
    },
  },
  mutations: {
    setPickupId (state, pickupId) {
      state.pickupId = pickupId
{'fraction_non_alphanumeric': 0.13352646826441927, 'fraction_numerical': 0.0, 'mean_word_length': 3.0970873786407767, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '3683763', 'n_tokens_mistral': 1153, 'n_tokens_neox': 1133, 'n_words': 277}