fix: delete provider crash

This commit is contained in:
kangfenmao 2024-07-30 15:30:09 +08:00
parent 17c3437e02
commit 925a9fb8ec
2 changed files with 2 additions and 2 deletions

View File

@ -47,7 +47,7 @@ export function useProvider(id: string) {
return { return {
provider, provider,
models: provider.models, models: provider?.models || [],
updateProvider: (provider: Provider) => dispatch(updateProvider(provider)), updateProvider: (provider: Provider) => dispatch(updateProvider(provider)),
addModel: (model: Model) => dispatch(addModel({ providerId: id, model })), addModel: (model: Model) => dispatch(addModel({ providerId: id, model })),
removeModel: (model: Model) => dispatch(removeModel({ providerId: id, model })) removeModel: (model: Model) => dispatch(removeModel({ providerId: id, model }))

View File

@ -94,7 +94,7 @@ export function droppableReorder<T>(list: T[], startIndex: number, endIndex: num
} }
export function firstLetter(str: string): string { export function firstLetter(str: string): string {
const match = str.match(/\p{L}\p{M}*|\p{Emoji_Presentation}|\p{Emoji}\uFE0F/u) const match = str?.match(/\p{L}\p{M}*|\p{Emoji_Presentation}|\p{Emoji}\uFE0F/u)
return match ? match[0] : '' return match ? match[0] : ''
} }