Skip to content

Commit

Permalink
Only render "create new space" btn if input is valid space name
Browse files Browse the repository at this point in the history
  • Loading branch information
poltak committed Jul 23, 2024
1 parent 29e95cd commit 0a54203
Showing 1 changed file with 5 additions and 22 deletions.
27 changes: 5 additions & 22 deletions src/custom-lists/ui/CollectionPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { runInBackground } from 'src/util/webextensionRPC'
import { ListTrees } from '../list-trees'
import { ListTreeToggleArrow } from '../list-trees/components/tree-toggle-arrow'
import { TooltipBox } from '@worldbrain/memex-common/lib/common-ui/components/tooltip-box'
import { validateSpaceName } from '@worldbrain/memex-common/lib/utils/space-name-validation'

export interface Props extends SpacePickerDependencies {
showPageLinks?: boolean
Expand Down Expand Up @@ -107,29 +108,11 @@ class SpacePicker extends StatefulUIElement<
return false
}

if (
this.state.newEntryName?.length > 0 &&
this.state.newEntryName[this.state.newEntryName?.length - 1]
?.unifiedId === null
) {
return true
} else {
return false
}

// const otherLists = normalizedStateToArray(this.state.listEntries).map(
// (e) => ({
// id: e.localId,
// name: e.name,
// }),
// )

// const newName =
// this.state.newEntryName?.[this.state.newEntryName.length - 1]
// ?.name ?? ''
const newName =
this.state.newEntryName?.[this.state.newEntryName.length - 1]
?.name ?? ''

// const validSpaceName = validateSpaceName(newName, otherLists).valid
// return validSpaceName
return validateSpaceName(newName, []).valid
}

private get selectedCacheListIds(): string[] {
Expand Down

0 comments on commit 0a54203

Please sign in to comment.