refactor: ♻️ Migrate from short-uuid to cuid lib
This commit is contained in:
@ -39,11 +39,11 @@ import { useRegisterActions } from 'kbar'
|
||||
import useUndo from 'services/utils/useUndo'
|
||||
import { useDebounce } from 'use-debounce'
|
||||
import { itemsAction, ItemsActions } from './actions/items'
|
||||
import { generate } from 'short-uuid'
|
||||
import { dequal } from 'dequal'
|
||||
import { User } from 'db'
|
||||
import { saveWebhook } from 'services/webhook'
|
||||
import { stringify } from 'qs'
|
||||
import cuid from 'cuid'
|
||||
const autoSaveTimeout = 10000
|
||||
|
||||
type UpdateTypebotPayload = Partial<{
|
||||
@ -291,7 +291,7 @@ export const TypebotContext = ({
|
||||
|
||||
const publishTypebot = async () => {
|
||||
if (!localTypebot) return
|
||||
const publishedTypebotId = generate()
|
||||
const publishedTypebotId = cuid()
|
||||
const newLocalTypebot = { ...localTypebot }
|
||||
if (publishedTypebot && isNotDefined(localTypebot.publishedTypebotId)) {
|
||||
updateLocalTypebot({ publishedTypebotId: publishedTypebot.id })
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { Typebot, Edge, StepWithItems, StepIndices, ItemIndices } from 'models'
|
||||
import { WritableDraft } from 'immer/dist/types/types-external'
|
||||
import { generate } from 'short-uuid'
|
||||
import { SetTypebot } from '../TypebotContext'
|
||||
import { produce } from 'immer'
|
||||
import { byId, isDefined, stepHasItems } from 'utils'
|
||||
import cuid from 'cuid'
|
||||
|
||||
export type EdgesActions = {
|
||||
createEdge: (edge: Omit<Edge, 'id'>) => void
|
||||
@ -17,7 +17,7 @@ export const edgesAction = (setTypebot: SetTypebot): EdgesActions => ({
|
||||
produce(typebot, (typebot) => {
|
||||
const newEdge = {
|
||||
...edge,
|
||||
id: generate(),
|
||||
id: cuid(),
|
||||
}
|
||||
removeExistingEdge(typebot, edge)
|
||||
typebot.edges.push(newEdge)
|
||||
@ -73,11 +73,10 @@ const addEdgeIdToItem = (
|
||||
typebot: WritableDraft<Typebot>,
|
||||
edgeId: string,
|
||||
{ blockIndex, stepIndex, itemIndex }: ItemIndices
|
||||
) => {
|
||||
;(typebot.blocks[blockIndex].steps[stepIndex] as StepWithItems).items[
|
||||
) =>
|
||||
((typebot.blocks[blockIndex].steps[stepIndex] as StepWithItems).items[
|
||||
itemIndex
|
||||
].outgoingEdgeId = edgeId
|
||||
}
|
||||
].outgoingEdgeId = edgeId)
|
||||
|
||||
export const deleteEdgeDraft = (
|
||||
typebot: WritableDraft<Typebot>,
|
||||
@ -107,11 +106,10 @@ const deleteOutgoingEdgeIdProps = (
|
||||
if (fromStepIndex !== -1)
|
||||
typebot.blocks[fromBlockIndex].steps[fromStepIndex].outgoingEdgeId =
|
||||
undefined
|
||||
if (fromItemIndex !== -1) {
|
||||
;(
|
||||
if (fromItemIndex !== -1)
|
||||
(
|
||||
typebot.blocks[fromBlockIndex].steps[fromStepIndex] as StepWithItems
|
||||
).items[fromItemIndex].outgoingEdgeId = undefined
|
||||
}
|
||||
}
|
||||
|
||||
export const cleanUpEdgeDraft = (
|
||||
|
@ -9,7 +9,7 @@ import { SetTypebot } from '../TypebotContext'
|
||||
import produce from 'immer'
|
||||
import { cleanUpEdgeDraft } from './edges'
|
||||
import { stepHasItems } from 'utils'
|
||||
import { generate } from 'short-uuid'
|
||||
import cuid from 'cuid'
|
||||
|
||||
export type ItemsActions = {
|
||||
createItem: (item: Omit<ButtonItem, 'id'>, indices: ItemIndices) => void
|
||||
@ -29,7 +29,7 @@ const itemsAction = (setTypebot: SetTypebot): ItemsActions => ({
|
||||
step.items.splice(itemIndex, 0, {
|
||||
...item,
|
||||
stepId: step.id,
|
||||
id: generate(),
|
||||
id: cuid(),
|
||||
})
|
||||
})
|
||||
),
|
||||
|
Reference in New Issue
Block a user