let pending = null

export function requestGalleryPick() {
  return new Promise((resolve, reject) => {
    pending = { resolve, reject }
    uni.$emit('salesperson:open-gallery')
  })
}

export function resolveGalleryPick(url) {
  if (pending) {
    pending.resolve(url)
    pending = null
  }
}

export function cancelGalleryPick() {
  if (pending) {
    pending.reject(new Error('cancel'))
    pending = null
  }
}
