abc sort fix
This commit is contained in:
parent
ee06ab54d2
commit
b1b3e12811
|
@ -8,6 +8,7 @@ import { useRouter } from '../../stores/router'
|
||||||
import styles from '../../styles/AllTopics.module.scss'
|
import styles from '../../styles/AllTopics.module.scss'
|
||||||
import { clsx } from 'clsx'
|
import { clsx } from 'clsx'
|
||||||
import { useSession } from '../../context/session'
|
import { useSession } from '../../context/session'
|
||||||
|
import { locale } from '../../stores/ui'
|
||||||
|
|
||||||
type AllAuthorsPageSearchParams = {
|
type AllAuthorsPageSearchParams = {
|
||||||
by: '' | 'name' | 'shouts' | 'rating'
|
by: '' | 'name' | 'shouts' | 'rating'
|
||||||
|
@ -35,18 +36,10 @@ export const AllAuthorsView = (props: Props) => {
|
||||||
|
|
||||||
const byLetter = createMemo<{ [letter: string]: Author[] }>(() => {
|
const byLetter = createMemo<{ [letter: string]: Author[] }>(() => {
|
||||||
return sortedAuthors().reduce((acc, author) => {
|
return sortedAuthors().reduce((acc, author) => {
|
||||||
if (!author.name) {
|
let letter = author.name.trim().split(' ').pop().at(0).toUpperCase()
|
||||||
// name === null for new users
|
if (!/[а-яА-Я]/i.test(letter) && locale() == 'ru') letter = '#'
|
||||||
return acc
|
if (!acc[letter]) acc[letter] = []
|
||||||
}
|
|
||||||
|
|
||||||
const letter = author.name[0].toUpperCase()
|
|
||||||
if (!acc[letter]) {
|
|
||||||
acc[letter] = []
|
|
||||||
}
|
|
||||||
|
|
||||||
acc[letter].push(author)
|
acc[letter].push(author)
|
||||||
|
|
||||||
return acc
|
return acc
|
||||||
}, {} as { [letter: string]: Author[] })
|
}, {} as { [letter: string]: Author[] })
|
||||||
})
|
})
|
||||||
|
|
|
@ -8,6 +8,7 @@ import { TopicCard } from '../Topic/Card'
|
||||||
import styles from '../../styles/AllTopics.module.scss'
|
import styles from '../../styles/AllTopics.module.scss'
|
||||||
import { clsx } from 'clsx'
|
import { clsx } from 'clsx'
|
||||||
import { useSession } from '../../context/session'
|
import { useSession } from '../../context/session'
|
||||||
|
import { locale } from '../../stores/ui'
|
||||||
|
|
||||||
type AllTopicsPageSearchParams = {
|
type AllTopicsPageSearchParams = {
|
||||||
by: 'shouts' | 'authors' | 'title' | ''
|
by: 'shouts' | 'authors' | 'title' | ''
|
||||||
|
@ -37,13 +38,10 @@ export const AllTopicsView = (props: AllTopicsViewProps) => {
|
||||||
|
|
||||||
const byLetter = createMemo<{ [letter: string]: Topic[] }>(() => {
|
const byLetter = createMemo<{ [letter: string]: Topic[] }>(() => {
|
||||||
return sortedTopics().reduce((acc, topic) => {
|
return sortedTopics().reduce((acc, topic) => {
|
||||||
const letter = topic.title[0].toUpperCase()
|
let letter = topic.title[0].toUpperCase()
|
||||||
if (!acc[letter]) {
|
if (!/[а-яА-Я]/i.test(letter) && locale() == 'ru') letter = '#'
|
||||||
acc[letter] = []
|
if (!acc[letter]) acc[letter] = []
|
||||||
}
|
|
||||||
|
|
||||||
acc[letter].push(topic)
|
acc[letter].push(topic)
|
||||||
|
|
||||||
return acc
|
return acc
|
||||||
}, {} as { [letter: string]: Topic[] })
|
}, {} as { [letter: string]: Topic[] })
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user